Mark chapters as read based on highest read chapter number during migration
This commit is contained in:
@@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
- (**Browse**) Merge languages filter of the sources and extensions into one
|
- (**Browse**) Merge languages filter of the sources and extensions into one
|
||||||
- (**Search**) Hide "pinned" sources button in global search in case no sources are pinned
|
- (**Search**) Hide "pinned" sources button in global search in case no sources are pinned
|
||||||
- (**Extensions**) Show "obsolete" information more discretely with the "uninstall" action instead of grouping obsolete extensions at the top of the page
|
- (**Extensions**) Show "obsolete" information more discretely with the "uninstall" action instead of grouping obsolete extensions at the top of the page
|
||||||
|
- (**Migration**) Mark all chapters as read up to the highest read chapter number. Previously matching chapter numbers got marked as read. E.g., Read up to chapter 250. The destination has a chapter 249.5 but the original source does not. Chapter 249.5 did not get marked as read.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -138,18 +138,27 @@ export class MangaMigration {
|
|||||||
const chaptersToMigrateTo = mangaToMigrateToInfo.fetchChapters?.chapters;
|
const chaptersToMigrateTo = mangaToMigrateToInfo.fetchChapters?.chapters;
|
||||||
const migratableChapters = Chapters.getMatchingChapterNumberChapters(chaptersToMigrate, chaptersToMigrateTo);
|
const migratableChapters = Chapters.getMatchingChapterNumberChapters(chaptersToMigrate, chaptersToMigrateTo);
|
||||||
|
|
||||||
const readChapters: number[] = [];
|
const highestReadChapterNumber = chaptersToMigrate.reduce((chapterNumber, chapterToMigrate) => {
|
||||||
|
if (chapterToMigrate.isRead && chapterNumber < chapterToMigrate.chapterNumber) {
|
||||||
|
return chapterToMigrate.chapterNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chapterNumber;
|
||||||
|
}, Number.MIN_SAFE_INTEGER);
|
||||||
|
|
||||||
const bookmarkedChapters: number[] = [];
|
const bookmarkedChapters: number[] = [];
|
||||||
|
|
||||||
const chapterPreDeleteIds: number[] = [];
|
const chapterPreDeleteIds: number[] = [];
|
||||||
const chapterUpdateItems: SetChapterMetasItemInput[] = [];
|
const chapterUpdateItems: SetChapterMetasItemInput[] = [];
|
||||||
|
|
||||||
migratableChapters.forEach(([chapterToMigrate, chapterToMigrateTo]) => {
|
const readChapters = Chapters.getIds(
|
||||||
const { isRead, isBookmarked, meta } = chapterToMigrate;
|
chaptersToMigrateTo.filter(
|
||||||
|
(chapterToMigrateTo) => chapterToMigrateTo.chapterNumber <= highestReadChapterNumber,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if (isRead) {
|
migratableChapters.forEach(([chapterToMigrate, chapterToMigrateTo]) => {
|
||||||
readChapters.push(chapterToMigrateTo.id);
|
const { isBookmarked, meta } = chapterToMigrate;
|
||||||
}
|
|
||||||
|
|
||||||
if (isBookmarked) {
|
if (isBookmarked) {
|
||||||
bookmarkedChapters.push(chapterToMigrateTo.id);
|
bookmarkedChapters.push(chapterToMigrateTo.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user