feat: implement epub service, navigation service, and global error boundary with updated reader UI layouts

This commit is contained in:
2026-04-25 16:16:36 +02:00
parent f3e94c4f42
commit 59074a05a0
23 changed files with 726 additions and 157 deletions
@@ -0,0 +1,38 @@
using System.Net.Http.Json;
using FluentResults;
using NexusReader.Application.Abstractions.Services;
using NexusReader.Application.Queries.Reader;
namespace NexusReader.Web.Client.Services;
public class WasmEpubService : IEpubService
{
private readonly HttpClient _httpClient;
public WasmEpubService(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<Result<ReaderPageViewModel>> GetEpubContentAsync(int chapterIndex)
{
try
{
var response = await _httpClient.GetAsync($"/api/epub/{chapterIndex}");
if (response.IsSuccessStatusCode)
{
var viewModel = await response.Content.ReadFromJsonAsync<ReaderPageViewModel>();
return viewModel != null ? Result.Ok(viewModel) : Result.Fail("Failed to deserialize response.");
}
// Try to read the error message from the body
var errorBody = await response.Content.ReadAsStringAsync();
return Result.Fail($"Server error ({response.StatusCode}): {errorBody}");
}
catch (Exception ex)
{
// Fallback for network errors or parsing exceptions
return Result.Fail(new Error($"Network or parsing error: {ex.Message}").CausedBy(ex));
}
}
}