using FluentResults;
using NexusReader.Application.Abstractions.Messaging;
using NexusReader.Application.Abstractions.Services;

namespace NexusReader.Application.Queries.Reader;

internal sealed class GetReaderPageQueryHandler : IQueryHandler<GetReaderPageQuery, ReaderPageViewModel>
{
    private readonly IEpubReader _epubReader;

    public GetReaderPageQueryHandler(IEpubReader epubReader)
    {
        _epubReader = epubReader;
    }

    public Task<Result<ReaderPageViewModel>> Handle(GetReaderPageQuery request, CancellationToken cancellationToken)
    {
        return _epubReader.GetEpubContentAsync(request.EbookId, request.ChapterIndex, request.UserId, cancellationToken);
    }
}
