Personal Table of Contents (#2148)
* Fixed a bad default setting for token key * Changed the payment link to support Google Pay * Fixed duplicate events occurring on newly added series from a scan. Fixed the version update code from not firing and made it check every 4-6 hours (random per user per restart) * Check for new releases on startup as well. Added Personal Table of Contents (called Bookmarks on epub and pdf reader). The idea is that sometimes you want to bookmark certain parts of pages to get back to quickly later. This mechanism will allow you to do that without having to edit the underlying ToC. * Added a button to update modal to show how to update for those unaware. * Darkened the link text within tables to be more visible. * Update link for how to update now is dynamic for docker users * Refactored to send proper star/end dates for scrobble read events for upcoming changes in the API. Added GoogleBooks Rating UI code if I go forward with API changes. * When Scrobbling, send when the first and last progress for the series was. Added OpenLibrary icon for upcoming enhancements for Kavita+. Changed the Update checker to execute at start. * Fixed backups not saving favicons in the correct place * Refactored the layout code for Personal ToC * More bugfixes around toc * Box alignment * Fixed up closing the overlay when bookmark mode is active * Fixed up closing the overlay when bookmark mode is active --------- Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
parent
f3b8074b3a
commit
a0a6da9c60
53 changed files with 3538 additions and 244 deletions
|
|
@ -31,6 +31,8 @@ public interface IAppUserProgressRepository
|
|||
Task<bool> AnyUserProgressForSeriesAsync(int seriesId, int userId);
|
||||
Task<int> GetHighestFullyReadChapterForSeries(int seriesId, int userId);
|
||||
Task<int> GetHighestFullyReadVolumeForSeries(int seriesId, int userId);
|
||||
Task<DateTime?> GetLatestProgressForSeries(int seriesId, int userId);
|
||||
Task<DateTime?> GetFirstProgressForSeries(int seriesId, int userId);
|
||||
}
|
||||
#nullable disable
|
||||
public class AppUserProgressRepository : IAppUserProgressRepository
|
||||
|
|
@ -179,7 +181,23 @@ public class AppUserProgressRepository : IAppUserProgressRepository
|
|||
return list.Count == 0 ? 0 : list.DefaultIfEmpty().Max();
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
public async Task<DateTime?> GetLatestProgressForSeries(int seriesId, int userId)
|
||||
{
|
||||
var list = await _context.AppUserProgresses.Where(p => p.AppUserId == userId && p.SeriesId == seriesId)
|
||||
.Select(p => p.LastModifiedUtc)
|
||||
.ToListAsync();
|
||||
return list.Count == 0 ? null : list.DefaultIfEmpty().Max();
|
||||
}
|
||||
|
||||
public async Task<DateTime?> GetFirstProgressForSeries(int seriesId, int userId)
|
||||
{
|
||||
var list = await _context.AppUserProgresses.Where(p => p.AppUserId == userId && p.SeriesId == seriesId)
|
||||
.Select(p => p.LastModifiedUtc)
|
||||
.ToListAsync();
|
||||
return list.Count == 0 ? null : list.DefaultIfEmpty().Min();
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
public async Task<AppUserProgress?> GetUserProgressAsync(int chapterId, int userId)
|
||||
{
|
||||
return await _context.AppUserProgresses
|
||||
|
|
|
|||
64
API/Data/Repositories/UserTableOfContentRepository.cs
Normal file
64
API/Data/Repositories/UserTableOfContentRepository.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.Reader;
|
||||
using API.Entities;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Data.Repositories;
|
||||
#nullable enable
|
||||
|
||||
public interface IUserTableOfContentRepository
|
||||
{
|
||||
void Attach(AppUserTableOfContent toc);
|
||||
void Remove(AppUserTableOfContent toc);
|
||||
Task<bool> IsUnique(int userId, int chapterId, int page, string title);
|
||||
IEnumerable<PersonalToCDto> GetPersonalToC(int userId, int chapterId);
|
||||
Task<AppUserTableOfContent?> Get(int userId, int chapterId, int pageNum, string title);
|
||||
}
|
||||
|
||||
public class UserTableOfContentRepository : IUserTableOfContentRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public UserTableOfContentRepository(DataContext context, IMapper mapper)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public void Attach(AppUserTableOfContent toc)
|
||||
{
|
||||
_context.AppUserTableOfContent.Attach(toc);
|
||||
}
|
||||
|
||||
public void Remove(AppUserTableOfContent toc)
|
||||
{
|
||||
_context.AppUserTableOfContent.Remove(toc);
|
||||
}
|
||||
|
||||
public async Task<bool> IsUnique(int userId, int chapterId, int page, string title)
|
||||
{
|
||||
return await _context.AppUserTableOfContent.AnyAsync(t =>
|
||||
t.AppUserId == userId && t.PageNumber == page && t.Title == title && t.ChapterId == chapterId);
|
||||
}
|
||||
|
||||
public IEnumerable<PersonalToCDto> GetPersonalToC(int userId, int chapterId)
|
||||
{
|
||||
return _context.AppUserTableOfContent
|
||||
.Where(t => t.AppUserId == userId && t.ChapterId == chapterId)
|
||||
.ProjectTo<PersonalToCDto>(_mapper.ConfigurationProvider)
|
||||
.OrderBy(t => t.PageNumber)
|
||||
.AsEnumerable();
|
||||
}
|
||||
|
||||
public async Task<AppUserTableOfContent?> Get(int userId,int chapterId, int pageNum, string title)
|
||||
{
|
||||
return await _context.AppUserTableOfContent
|
||||
.Where(t => t.AppUserId == userId && t.ChapterId == chapterId && t.PageNumber == pageNum && t.Title == title)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue