Properly handle not skipping duplicate chapters
The filtered chapter list of the reader state always incorrectly filtered out duplicated chapters even while the setting was disabled
This commit is contained in:
@@ -191,7 +191,7 @@ const BaseReaderViewer = forwardRef(
|
||||
const isLtrReadingDirection = readingDirection === ReadingDirection.LTR;
|
||||
const initialChapterIndex = useMemo(
|
||||
() => chapters.findIndex((chapter) => chapter.id === initialChapter?.id),
|
||||
[initialChapter?.id],
|
||||
[chapters, initialChapter?.id],
|
||||
);
|
||||
const chaptersToRender = useMemo(
|
||||
() =>
|
||||
@@ -199,7 +199,7 @@ const BaseReaderViewer = forwardRef(
|
||||
Math.max(0, initialChapterIndex - visibleChapters.trailing),
|
||||
Math.min(chapters.length, initialChapterIndex + visibleChapters.leading + 1),
|
||||
),
|
||||
[chapters, initialChapterIndex, visibleChapters.trailing, visibleChapters.leading, chapters.length],
|
||||
[chapters, initialChapterIndex, visibleChapters.trailing, visibleChapters.leading],
|
||||
);
|
||||
const currentChapterIndex = useMemo(
|
||||
() => chaptersToRender.findIndex((chapter) => chapter.id === currentChapter?.id),
|
||||
|
||||
@@ -46,6 +46,17 @@ export const useReaderSetChaptersState = (
|
||||
skipDupe: shouldSkipDupChapters,
|
||||
skipDupeChapter: newChapterForDuplicatesHandling,
|
||||
});
|
||||
const newChapters = (() => {
|
||||
if (!newMangaChapters || !newChapterForDuplicatesHandling) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (shouldSkipDupChapters) {
|
||||
return Chapters.removeDuplicates(newChapterForDuplicatesHandling, newMangaChapters);
|
||||
}
|
||||
|
||||
return newMangaChapters;
|
||||
})();
|
||||
|
||||
const hasInitialChapterChanged = newInitialChapter != null && newInitialChapter.id !== initialChapter?.id;
|
||||
|
||||
@@ -54,10 +65,7 @@ export const useReaderSetChaptersState = (
|
||||
return {
|
||||
...prevState,
|
||||
mangaChapters: newMangaChapters ?? [],
|
||||
chapters:
|
||||
newChapterForDuplicatesHandling && newMangaChapters
|
||||
? Chapters.removeDuplicates(newChapterForDuplicatesHandling, newMangaChapters)
|
||||
: [],
|
||||
chapters: newChapters,
|
||||
initialChapter: newInitialChapter,
|
||||
chapterForDuplicatesHandling: newChapterForDuplicatesHandling,
|
||||
currentChapter: newCurrentChapter,
|
||||
|
||||
Reference in New Issue
Block a user