mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 22:35:17 -04:00
OPDS Enhancements, Epub fixes, and a lot more (#4035)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com> Co-authored-by: Fabian Pammer <fpammer@mantro.net> Co-authored-by: Vinícius Licz <vinilicz@gmail.com>
This commit is contained in:
@@ -40,10 +40,12 @@ public interface IChapterRepository
|
||||
Task<IChapterInfoDto?> GetChapterInfoDtoAsync(int chapterId);
|
||||
Task<int> GetChapterTotalPagesAsync(int chapterId);
|
||||
Task<Chapter?> GetChapterAsync(int chapterId, ChapterIncludes includes = ChapterIncludes.Files);
|
||||
Task<ChapterDto?> GetChapterDtoAsync(int chapterId, ChapterIncludes includes = ChapterIncludes.Files);
|
||||
Task<ChapterDto?> GetChapterDtoAsync(int chapterId, int userId);
|
||||
Task<IList<ChapterDto>> GetChapterDtoByIdsAsync(IEnumerable<int> chapterIds, int userId);
|
||||
Task<ChapterMetadataDto?> GetChapterMetadataDtoAsync(int chapterId, ChapterIncludes includes = ChapterIncludes.Files);
|
||||
Task<IList<MangaFile>> GetFilesForChapterAsync(int chapterId);
|
||||
Task<IList<Chapter>> GetChaptersAsync(int volumeId, ChapterIncludes includes = ChapterIncludes.None);
|
||||
Task<IList<ChapterDto>> GetChapterDtosAsync(int volumeId, int userId);
|
||||
Task<IList<MangaFile>> GetFilesForChaptersAsync(IReadOnlyList<int> chapterIds);
|
||||
Task<string?> GetChapterCoverImageAsync(int chapterId);
|
||||
Task<IList<string>> GetAllCoverImagesAsync();
|
||||
@@ -153,18 +155,39 @@ public class ChapterRepository : IChapterRepository
|
||||
.Select(c => c.Pages)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<ChapterDto?> GetChapterDtoAsync(int chapterId, ChapterIncludes includes = ChapterIncludes.Files)
|
||||
public async Task<ChapterDto?> GetChapterDtoAsync(int chapterId, int userId)
|
||||
{
|
||||
var chapter = await _context.Chapter
|
||||
.Includes(includes)
|
||||
.Includes(ChapterIncludes.Files | ChapterIncludes.People)
|
||||
.ProjectTo<ChapterDto>(_mapper.ConfigurationProvider)
|
||||
.AsNoTracking()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(c => c.Id == chapterId);
|
||||
|
||||
if (userId > 0 && chapter != null)
|
||||
{
|
||||
await AddChapterModifiers(userId, chapter);
|
||||
}
|
||||
|
||||
return chapter;
|
||||
}
|
||||
|
||||
public async Task<IList<ChapterDto>> GetChapterDtoByIdsAsync(IEnumerable<int> chapterIds, int userId)
|
||||
{
|
||||
var chapters = await _context.Chapter
|
||||
.Where(c => chapterIds.Contains(c.Id))
|
||||
.Includes(ChapterIncludes.Files | ChapterIncludes.People)
|
||||
.ProjectTo<ChapterDto>(_mapper.ConfigurationProvider)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync() ;
|
||||
|
||||
foreach (var chapter in chapters)
|
||||
{
|
||||
await AddChapterModifiers(userId, chapter);
|
||||
}
|
||||
|
||||
return chapters;
|
||||
}
|
||||
|
||||
public async Task<ChapterMetadataDto?> GetChapterMetadataDtoAsync(int chapterId, ChapterIncludes includes = ChapterIncludes.Files)
|
||||
{
|
||||
var chapter = await _context.Chapter
|
||||
@@ -218,6 +241,28 @@ public class ChapterRepository : IChapterRepository
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Chapters for a volume id with Progress
|
||||
/// </summary>
|
||||
/// <param name="volumeId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IList<ChapterDto>> GetChapterDtosAsync(int volumeId, int userId)
|
||||
{
|
||||
var chapts = await _context.Chapter
|
||||
.Where(c => c.VolumeId == volumeId)
|
||||
.Includes(ChapterIncludes.Files | ChapterIncludes.People)
|
||||
.OrderBy(c => c.SortOrder)
|
||||
.ProjectTo<ChapterDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var chapter in chapts)
|
||||
{
|
||||
await AddChapterModifiers(userId, chapter);
|
||||
}
|
||||
|
||||
return chapts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cover image for a chapter id.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user