qwen edit
This commit is contained in:
@@ -90,6 +90,20 @@ public partial class ReaderViewModel : BaseViewModel
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
// Валидация: книга должна быть загружена
|
||||
if (Book == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[ReaderViewModel] Book is null, cannot initialize");
|
||||
return;
|
||||
}
|
||||
|
||||
// Валидация: файл книги должен существовать
|
||||
if (!File.Exists(Book.FilePath))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[ReaderViewModel] Book file not found: {Book.FilePath}");
|
||||
return;
|
||||
}
|
||||
|
||||
var savedFontSize = await _settingsService.GetIntAsync(SettingsKeys.DefaultFontSize, 18);
|
||||
var savedFontFamily = await _settingsService.GetAsync(SettingsKeys.DefaultFontFamily, "serif");
|
||||
|
||||
@@ -145,15 +159,22 @@ public partial class ReaderViewModel : BaseViewModel
|
||||
|
||||
public async Task SaveLocationsAsync(string locations)
|
||||
{
|
||||
if (Book == null) return;
|
||||
if (Book == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[ReaderViewModel] Cannot save locations: Book is null");
|
||||
return;
|
||||
}
|
||||
Book.Locations = locations;
|
||||
// Сохраняем в базу данных
|
||||
await _databaseService.UpdateBookAsync(Book);
|
||||
}
|
||||
|
||||
public async Task SaveProgressAsync(double progress, string? cfi, string? chapter, int currentPage, int totalPages)
|
||||
{
|
||||
if (Book == null) return;
|
||||
if (Book == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[ReaderViewModel] Cannot save progress: Book is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Важно: если CFI пустой, не перезаписываем старый прогресс (защита от багов JS)
|
||||
if (string.IsNullOrEmpty(cfi) && progress <= 0) return;
|
||||
@@ -165,7 +186,6 @@ public partial class ReaderViewModel : BaseViewModel
|
||||
Book.TotalPages = totalPages;
|
||||
Book.LastRead = DateTime.UtcNow;
|
||||
|
||||
// Сохраняем в базу данных
|
||||
await _databaseService.UpdateBookAsync(Book);
|
||||
|
||||
await _databaseService.SaveProgressAsync(new ReadingProgress
|
||||
|
||||
Reference in New Issue
Block a user