From 5b459206ccb37b8200280bc136c69c2f72a3623e Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 17 May 2026 00:18:51 +0200 Subject: [PATCH] Optionally ignore outdated matches during bulk migration The original "ignore outdated matches" setting added with 3d514d357a8c514a46ce08032470742b67047567 is not really ignoring outdated matches but requires matches to be ahead of the current source. The variable naming is not matching the logic and is confusing. --- CHANGELOG.md | 4 +++ src/features/migration/Migration.types.ts | 1 + src/features/migration/MigrationManager.ts | 8 +++-- .../MigrationBulkSearchOptionsDialog.tsx | 29 +++++++++++++++++-- src/i18n/locales/en.po | 8 +++++ 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef5ab1e..a40b6cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## [Unreleased] (Preview) +### Added + +- (**Migration**) Add a search option to ignore outdated matches + ### Changed - (**Migration**) Show "abort" button during active bulk migration search diff --git a/src/features/migration/Migration.types.ts b/src/features/migration/Migration.types.ts index a5bb9447..ec8cb674 100644 --- a/src/features/migration/Migration.types.ts +++ b/src/features/migration/Migration.types.ts @@ -72,6 +72,7 @@ export type MetadataMigrationSettings = { export interface MigrationBulkSearchSettings { selectHighestChapterNumberSource: boolean; ignoreOutdatedMatches: boolean; + requireAdditionalChapters: boolean; performAdvancedSearch: boolean; } diff --git a/src/features/migration/MigrationManager.ts b/src/features/migration/MigrationManager.ts index e84d0b0d..a8ea2706 100644 --- a/src/features/migration/MigrationManager.ts +++ b/src/features/migration/MigrationManager.ts @@ -801,7 +801,7 @@ export class MigrationManager { mainSignal: AbortSignal, options: MigrationBulkSearchSettings, ): Promise { - const { selectHighestChapterNumberSource, ignoreOutdatedMatches } = options; + const { selectHighestChapterNumberSource, ignoreOutdatedMatches, requireAdditionalChapters } = options; const state = MigrationManager.getState(); const entry = state.entries[mangaId]; @@ -909,6 +909,8 @@ export class MigrationManager { latestChapterNumber > selectedMatchLatestChapterNumber; const hasNewerChapter = hasNewerChapterVsEntry && hasNewerChapterVsSelectedMatch; + const isOutdated = latestChapterNumber <= entryLatestChapterNumber; + const hasSameLatestChapterAsSelectedMatch = !!draftMatchEntry && selectedMatchLatestChapterNumber === latestChapterNumber; @@ -917,7 +919,8 @@ export class MigrationManager { destSourceId, ); - const ignoreOutdatedMatch = ignoreOutdatedMatches && !hasNewerChapter; + const ignoreOutdatedMatch = ignoreOutdatedMatches && isOutdated; + const satisfiesRequireAdditionalChapters = !requireAdditionalChapters || hasNewerChapter; const isPreferredSourcePriorityMatch = hasHigherSourcePriority && !selectHighestChapterNumberSource; const isPreferredChapterNumberMatch = @@ -929,6 +932,7 @@ export class MigrationManager { const isPreferredMatch = !draftEntry.isManualSelection && !ignoreOutdatedMatch && + satisfiesRequireAdditionalChapters && (isPreferredSourcePriorityMatch || isPreferredChapterNumberMatch); if (isPreferredMatch) { draftEntry.selectedMatchMangaId = bestMatch.id; diff --git a/src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx b/src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx index 9a5f5623..2e5977d2 100644 --- a/src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx +++ b/src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx @@ -29,13 +29,35 @@ export const MigrationBulkSearchOptionsDialog = ({ const { t } = useLingui(); const [selectHighestChapterNumberSource, setSelectHighestChapterNumberSource] = useState(false); - const [ignoreOutdatedMatches, setIgnoreOutdatesMatches] = useState(false); + const [ignoreOutdatedMatches, setIgnoreOutdatedMatches] = useState(false); + const [requireAdditionalChapters, setRequireAdditionalChapters] = useState(false); const [performAdvancedSearch, setPerformAdvancedSearch] = useState(false); return ( {t`Search options`} + + {t`Ignore matches that are behind in chapters`} + {t`Only automatically select matches if they have at least the same latest chapter. They will still be shown in the found matches`} + + } + sx={{ + alignItems: 'start', + }} + checked={ignoreOutdatedMatches} + onChange={(_, checked) => setIgnoreOutdatedMatches(checked)} + /> setIgnoreOutdatesMatches(checked)} + checked={requireAdditionalChapters} + onChange={(_, checked) => setRequireAdditionalChapters(checked)} /> @@ -129,6 +151,7 @@ export const MigrationBulkSearchOptionsDialog = ({ onSubmit({ selectHighestChapterNumberSource, ignoreOutdatedMatches, + requireAdditionalChapters, performAdvancedSearch, }) } diff --git a/src/i18n/locales/en.po b/src/i18n/locales/en.po index 819ec167..5272c898 100644 --- a/src/i18n/locales/en.po +++ b/src/i18n/locales/en.po @@ -1845,6 +1845,10 @@ msgstr "Ignore automatic chapter downloads for entries with unread chapters" msgid "Ignore filters when searching" msgstr "Ignore filters when searching" +#: src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx +msgid "Ignore matches that are behind in chapters" +msgstr "Ignore matches that are behind in chapters" + #: src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx msgid "Ignore matches without newer chapters" msgstr "Ignore matches without newer chapters" @@ -2558,6 +2562,10 @@ msgstr "Ongoing" msgid "Only automatically select matches if they have additional chapters. They will still be shown in the found matches" msgstr "Only automatically select matches if they have additional chapters. They will still be shown in the found matches" +#: src/features/migration/components/MigrationBulkSearchOptionsDialog.tsx +msgid "Only automatically select matches if they have at least the same latest chapter. They will still be shown in the found matches" +msgstr "Only automatically select matches if they have at least the same latest chapter. They will still be shown in the found matches" + #: src/features/migration/Migration.constants.ts msgid "Only outdated matches found" msgstr "Only outdated matches found"