Ignore duplicated chapters for download limits
In case the next 5 chapters should get downloaded and they are all the same chapter from different scanlators, then the download actually only included 1 chapter. To fix this duplicated chapters are counted as 1 chapter
This commit is contained in:
@@ -305,6 +305,18 @@ export class Chapters {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provided "uniqueChapters" plus their duplicates found in "allChapters"
|
||||
*/
|
||||
static addDuplicates<T extends ChapterScanlatorInfo & ChapterNumberInfo>(
|
||||
uniqueChapters: T[],
|
||||
allChapters: T[],
|
||||
): T[] {
|
||||
const chapterNumberToChapters = Object.groupBy(allChapters, ({ chapterNumber }) => chapterNumber);
|
||||
|
||||
return uniqueChapters.map(({ chapterNumber }) => chapterNumberToChapters[chapterNumber]!).flat();
|
||||
}
|
||||
|
||||
static removeDuplicates<T extends ChapterScanlatorInfo & ChapterNumberInfo>(currentChapter: T, chapters: T[]): T[] {
|
||||
const chapterNumberToChapters = Object.groupBy(chapters, ({ chapterNumber }) => chapterNumber);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user