feat: implement real-time reading progress and refactor profile to CQRS

This commit is contained in:
2026-05-10 18:15:29 +02:00
parent 10dc511f2a
commit b456194ea1
20 changed files with 1738 additions and 96 deletions
@@ -4,14 +4,23 @@ using FluentResults;
using NexusReader.Application.Abstractions.Services;
using NexusReader.Application.Queries.Reader;
using VersOne.Epub;
using Microsoft.EntityFrameworkCore;
using NexusReader.Data.Persistence;
using NexusReader.Domain.Entities;
namespace NexusReader.Infrastructure.Services;
public class EpubService : IEpubService
{
private readonly IDbContextFactory<AppDbContext> _dbContextFactory;
private const string EpubPath = "wwwroot/assets/book.epub";
private const int WordThreshold = 1000;
public EpubService(IDbContextFactory<AppDbContext> dbContextFactory)
{
_dbContextFactory = dbContextFactory;
}
public async Task<Result<ReaderPageViewModel>> GetEpubContentAsync(int chapterIndex)
{
try
@@ -100,7 +109,14 @@ public class EpubService : IEpubService
blocks.Add(CreateAiTrigger($"trigger-{blockCounter++}"));
}
return Result.Ok(new ReaderPageViewModel(blocks, chapterIndex, readingOrder.Count, chapterTitle));
// Find the EbookId from DB for this file
using var context = await _dbContextFactory.CreateDbContextAsync();
var ebookId = await context.Ebooks
.Where(e => e.FilePath.Contains("book.epub"))
.Select(e => e.Id)
.FirstOrDefaultAsync();
return Result.Ok(new ReaderPageViewModel(blocks, chapterIndex, readingOrder.Count, chapterTitle, ebookId));
}
catch (Exception ex)
{