Fix deletion of chapters while reading logic
- Consider duplicated chapters in "should delete chapter" check - Check each duplicate if it can be deleted
This commit is contained in:
@@ -55,27 +55,26 @@ export const getChapterIdsToDeleteForChapterUpdate = (
|
||||
return [];
|
||||
}
|
||||
|
||||
const chapterToDelete = [chapter, ...previousChapters][deleteChaptersWhileReading - 1];
|
||||
if (!chapterToDelete) {
|
||||
const maybeChapterToDelete = [chapter, ...previousChapters][deleteChaptersWhileReading - 1];
|
||||
if (!maybeChapterToDelete) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const chapterToDeleteUpToDateData = getReaderChapterFromCache(chapterToDelete.id);
|
||||
if (!chapterToDeleteUpToDateData) {
|
||||
const maybeChaptersToDelete = shouldSkipDupChapters
|
||||
? Chapters.addDuplicates([maybeChapterToDelete], chapters)
|
||||
: [maybeChapterToDelete];
|
||||
const chaptersToDelete = maybeChaptersToDelete
|
||||
.map(({ id }) => getReaderChapterFromCache(id))
|
||||
.filter((chapterToDeleteUpToDateData) => chapterToDeleteUpToDateData !== null)
|
||||
.filter((chapterToDeleteUpToDateData) =>
|
||||
Chapters.isDeletable(chapterToDeleteUpToDateData, deleteChaptersWithBookmark),
|
||||
);
|
||||
|
||||
if (!chaptersToDelete.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const shouldDeleteChapter =
|
||||
patch.isRead && Chapters.isDeletable(chapterToDeleteUpToDateData, deleteChaptersWithBookmark);
|
||||
if (!shouldDeleteChapter) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!shouldSkipDupChapters) {
|
||||
return Chapters.getIds([chapterToDelete]);
|
||||
}
|
||||
|
||||
return Chapters.getIds(Chapters.addDuplicates([chapterToDelete], chapters));
|
||||
return Chapters.getIds(chaptersToDelete);
|
||||
};
|
||||
|
||||
export const isInDownloadAheadRange = (
|
||||
|
||||
Reference in New Issue
Block a user