Reading List Polish (#1879)
* Use Reading Order to count epub pages rather than raw HTML files. * Send email on background thread for initial invite flow. * Reorder default writing style for new users so Horizontal is default * Changed reading activity to use average hours read rather than events to bring more meaningful data. * added ability to start reading incognito from the top of series detail, needs a bit of styling help though. * Refactored extensions out into their own package, added new fields for reading list to cover total run, cbl import now takes those dates and overrides on import. Replaced many instances of numbers to be comma separated. * Added ability to edit reading list run start and end year/month. Refactored some code for valid month/year into a helper method. * Added a way to see the reading list's release years. * Added some merged image code, but had to remove due to cover dimensions not fixed. * tweaked style for accessibility mode on reading list items * Tweaked css for non virtualized and virtualized containers * Fixed release updates failing * Commented out the merge code. * Typo on words read per year * Fixed unit tests * Fixed virtualized scroll * Cleanup CSS
This commit is contained in:
parent
266f302823
commit
fd6ee42f5f
60 changed files with 2847 additions and 430 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -10,6 +11,7 @@ using API.DTOs.ReadingLists;
|
|||
using API.DTOs.ReadingLists.CBL;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Helpers;
|
||||
using API.SignalR;
|
||||
using Kavita.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -31,6 +33,8 @@ public interface IReadingListService
|
|||
|
||||
Task<CblImportSummaryDto> ValidateCblFile(int userId, CblReadingList cblReading);
|
||||
Task<CblImportSummaryDto> CreateReadingListFromCbl(int userId, CblReadingList cblReading, bool dryRun = false);
|
||||
Task CalculateStartAndEndDates(ReadingList readingListWithItems);
|
||||
Task<string> GenerateMergedImage(int readingListId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -142,6 +146,25 @@ public class ReadingListService : IReadingListService
|
|||
readingList.Promoted = dto.Promoted;
|
||||
readingList.CoverImageLocked = dto.CoverImageLocked;
|
||||
|
||||
|
||||
if (NumberHelper.IsValidMonth(dto.StartingMonth))
|
||||
{
|
||||
readingList.StartingMonth = dto.StartingMonth;
|
||||
}
|
||||
if (NumberHelper.IsValidYear(dto.StartingYear))
|
||||
{
|
||||
readingList.StartingYear = dto.StartingYear;
|
||||
}
|
||||
if (NumberHelper.IsValidMonth(dto.EndingMonth))
|
||||
{
|
||||
readingList.EndingMonth = dto.EndingMonth;
|
||||
}
|
||||
if (NumberHelper.IsValidYear(dto.EndingYear))
|
||||
{
|
||||
readingList.EndingYear = dto.EndingYear;
|
||||
}
|
||||
|
||||
|
||||
if (!dto.CoverImageLocked)
|
||||
{
|
||||
readingList.CoverImageLocked = false;
|
||||
|
@ -182,6 +205,7 @@ public class ReadingListService : IReadingListService
|
|||
var readingList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(readingListId);
|
||||
if (readingList == null) return true;
|
||||
await CalculateReadingListAgeRating(readingList);
|
||||
await CalculateStartAndEndDates(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return true;
|
||||
|
||||
|
@ -239,6 +263,7 @@ public class ReadingListService : IReadingListService
|
|||
}
|
||||
|
||||
await CalculateReadingListAgeRating(readingList);
|
||||
await CalculateStartAndEndDates(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return true;
|
||||
|
||||
|
@ -254,6 +279,52 @@ public class ReadingListService : IReadingListService
|
|||
await CalculateReadingListAgeRating(readingList, readingList.Items.Select(i => i.SeriesId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the Start month/year and Ending month/year
|
||||
/// </summary>
|
||||
/// <param name="readingListWithItems">Reading list should have all items</param>
|
||||
public async Task CalculateStartAndEndDates(ReadingList readingListWithItems)
|
||||
{
|
||||
var items = readingListWithItems.Items;
|
||||
if (readingListWithItems.Items.All(i => i.Chapter == null))
|
||||
{
|
||||
items =
|
||||
(await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(readingListWithItems.Id, ReadingListIncludes.ItemChapter))?.Items;
|
||||
}
|
||||
if (items == null || items.Count == 0) return;
|
||||
|
||||
if (items.First().Chapter == null)
|
||||
{
|
||||
_logger.LogError("Tried to calculate release dates for Reading List, but missing Chapter entities");
|
||||
return;
|
||||
}
|
||||
var maxReleaseDate = items.Max(item => item.Chapter.ReleaseDate);
|
||||
var minReleaseDate = items.Max(item => item.Chapter.ReleaseDate);
|
||||
if (maxReleaseDate != DateTime.MinValue)
|
||||
{
|
||||
readingListWithItems.EndingMonth = maxReleaseDate.Month;
|
||||
readingListWithItems.EndingYear = maxReleaseDate.Year;
|
||||
}
|
||||
if (minReleaseDate != DateTime.MinValue)
|
||||
{
|
||||
readingListWithItems.StartingMonth = minReleaseDate.Month;
|
||||
readingListWithItems.StartingYear = minReleaseDate.Year;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<string?> GenerateMergedImage(int readingListId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// var coverImages = (await _unitOfWork.ReadingListRepository.GetFirstFourCoverImagesByReadingListId(readingListId)).ToList();
|
||||
// if (coverImages.Count < 4) return null;
|
||||
// var fullImages = coverImages
|
||||
// .Select(c => _directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, c)).ToList();
|
||||
//
|
||||
// var combinedFile = ImageService.CreateMergedImage(fullImages, _directoryService.FileSystem.Path.Join(_directoryService.TempDirectory, $"{readingListId}.png"));
|
||||
// // webp needs to be handled
|
||||
// return combinedFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the highest Age Rating from each Reading List Item
|
||||
/// </summary>
|
||||
|
@ -522,6 +593,14 @@ public class ReadingListService : IReadingListService
|
|||
if (dryRun) return importSummary;
|
||||
|
||||
await CalculateReadingListAgeRating(readingList);
|
||||
await CalculateStartAndEndDates(readingList);
|
||||
|
||||
// For CBL Import only we override pre-calculated dates
|
||||
if (NumberHelper.IsValidMonth(cblReading.StartMonth)) readingList.StartingMonth = cblReading.StartMonth;
|
||||
if (NumberHelper.IsValidYear(cblReading.StartYear)) readingList.StartingYear = cblReading.StartYear;
|
||||
if (NumberHelper.IsValidMonth(cblReading.EndMonth)) readingList.EndingMonth = cblReading.EndMonth;
|
||||
if (NumberHelper.IsValidYear(cblReading.EndYear)) readingList.EndingYear = cblReading.EndYear;
|
||||
|
||||
if (!string.IsNullOrEmpty(readingList.Summary?.Trim()))
|
||||
{
|
||||
readingList.Summary = readingList.Summary?.Trim();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue