Keep initial opened chapter as duplicate reference

In case "skip duplicated chapters" is enabled and the next chapter is from a different scanlator, the initial opened chapter should still be used to remove duplicated chapters.

Otherwise, the original scanlator would get lost and the scanlator of the next chapter would get used, which was only a fallback chapter, because the initial chapters scanlator did not have a next chapter.
This commit is contained in:
schroda
2024-05-13 04:04:41 +02:00
parent ca747b383e
commit a65ca228fe
2 changed files with 36 additions and 16 deletions

View File

@@ -342,7 +342,7 @@ export class Chapters {
{
offset = ChapterOffset.NEXT,
...options
}: { offset?: ChapterOffset; onlyUnread?: boolean; skipDupe?: boolean } = {},
}: { offset?: ChapterOffset; onlyUnread?: boolean; skipDupe?: boolean; skipDupeChapter?: Chapter } = {},
): Chapter | undefined {
const nextChapters = Chapters.getNextChapters(currentChapter, chapters, { offset, ...options });
@@ -360,7 +360,8 @@ export class Chapters {
offset = ChapterOffset.NEXT,
onlyUnread = false,
skipDupe = false,
}: { offset?: ChapterOffset; onlyUnread?: boolean; skipDupe?: boolean } = {},
skipDupeChapter = fromChapter,
}: { offset?: ChapterOffset; onlyUnread?: boolean; skipDupe?: boolean; skipDupeChapter?: Chapter } = {},
): Chapter[] {
const fromChapterIndex = chapters.findIndex((chapter) => chapter.id === fromChapter.id);
@@ -370,7 +371,7 @@ export class Chapters {
const nextChaptersIncludingCurrent = chapters.slice(sliceStartIndex, sliceEndIndex);
const uniqueNextChapters = skipDupe
? Chapters.removeDuplicates(fromChapter, nextChaptersIncludingCurrent)
? Chapters.removeDuplicates(skipDupeChapter, nextChaptersIncludingCurrent)
: nextChaptersIncludingCurrent;
const nextChapters = uniqueNextChapters.toSpliced(isNextChapterOffset ? -1 : 0, 1);