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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const chapterToDelete = [chapter, ...previousChapters][deleteChaptersWhileReading - 1];
|
const maybeChapterToDelete = [chapter, ...previousChapters][deleteChaptersWhileReading - 1];
|
||||||
if (!chapterToDelete) {
|
if (!maybeChapterToDelete) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const chapterToDeleteUpToDateData = getReaderChapterFromCache(chapterToDelete.id);
|
const maybeChaptersToDelete = shouldSkipDupChapters
|
||||||
if (!chapterToDeleteUpToDateData) {
|
? 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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldDeleteChapter =
|
return Chapters.getIds(chaptersToDelete);
|
||||||
patch.isRead && Chapters.isDeletable(chapterToDeleteUpToDateData, deleteChaptersWithBookmark);
|
|
||||||
if (!shouldDeleteChapter) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!shouldSkipDupChapters) {
|
|
||||||
return Chapters.getIds([chapterToDelete]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Chapters.getIds(Chapters.addDuplicates([chapterToDelete], chapters));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isInDownloadAheadRange = (
|
export const isInDownloadAheadRange = (
|
||||||
|
|||||||
Reference in New Issue
Block a user