Optionally ignore outdated matches during bulk migration

The original "ignore outdated matches" setting added with 3d514d357a 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.
This commit is contained in:
schroda
2026-05-17 00:18:51 +02:00
parent b7730ffcf9
commit 5b459206cc
5 changed files with 45 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ export type MetadataMigrationSettings = {
export interface MigrationBulkSearchSettings {
selectHighestChapterNumberSource: boolean;
ignoreOutdatedMatches: boolean;
requireAdditionalChapters: boolean;
performAdvancedSearch: boolean;
}

View File

@@ -801,7 +801,7 @@ export class MigrationManager {
mainSignal: AbortSignal,
options: MigrationBulkSearchSettings,
): Promise<void> {
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;

View File

@@ -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 (
<Dialog open={isVisible} fullWidth onClose={onDismiss} onTransitionExited={onExitComplete}>
<DialogTitle>{t`Search options`}</DialogTitle>
<DialogContent dividers>
<CheckboxInput
label={
<Stack
sx={{
// Padding comes from the MUI Checkbox component
pt: '9px',
}}
>
<Typography>{t`Ignore matches that are behind in chapters`}</Typography>
<Typography
variant="body2"
color="textSecondary"
>{t`Only automatically select matches if they have at least the same latest chapter. They will still be shown in the found matches`}</Typography>
</Stack>
}
sx={{
alignItems: 'start',
}}
checked={ignoreOutdatedMatches}
onChange={(_, checked) => setIgnoreOutdatedMatches(checked)}
/>
<CheckboxInput
label={
<Stack
@@ -54,8 +76,8 @@ export const MigrationBulkSearchOptionsDialog = ({
sx={{
alignItems: 'start',
}}
checked={ignoreOutdatedMatches}
onChange={(_, checked) => setIgnoreOutdatesMatches(checked)}
checked={requireAdditionalChapters}
onChange={(_, checked) => setRequireAdditionalChapters(checked)}
/>
</DialogContent>
<DialogContent dividers>
@@ -129,6 +151,7 @@ export const MigrationBulkSearchOptionsDialog = ({
onSubmit({
selectHighestChapterNumberSource,
ignoreOutdatedMatches,
requireAdditionalChapters,
performAdvancedSearch,
})
}

View File

@@ -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"