diff --git a/CHANGELOG.md b/CHANGELOG.md index e0abf84d..4fe3d828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - (**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 +- (**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 diff --git a/src/features/migration/MangaMigration.ts b/src/features/migration/MangaMigration.ts index 4fb786c9..4a50fa88 100644 --- a/src/features/migration/MangaMigration.ts +++ b/src/features/migration/MangaMigration.ts @@ -138,18 +138,27 @@ export class MangaMigration { const chaptersToMigrateTo = mangaToMigrateToInfo.fetchChapters?.chapters; 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 chapterPreDeleteIds: number[] = []; const chapterUpdateItems: SetChapterMetasItemInput[] = []; - migratableChapters.forEach(([chapterToMigrate, chapterToMigrateTo]) => { - const { isRead, isBookmarked, meta } = chapterToMigrate; + const readChapters = Chapters.getIds( + chaptersToMigrateTo.filter( + (chapterToMigrateTo) => chapterToMigrateTo.chapterNumber <= highestReadChapterNumber, + ), + ); - if (isRead) { - readChapters.push(chapterToMigrateTo.id); - } + migratableChapters.forEach(([chapterToMigrate, chapterToMigrateTo]) => { + const { isBookmarked, meta } = chapterToMigrate; if (isBookmarked) { bookmarkedChapters.push(chapterToMigrateTo.id);