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:
@@ -72,6 +72,7 @@ export type MetadataMigrationSettings = {
|
||||
export interface MigrationBulkSearchSettings {
|
||||
selectHighestChapterNumberSource: boolean;
|
||||
ignoreOutdatedMatches: boolean;
|
||||
requireAdditionalChapters: boolean;
|
||||
performAdvancedSearch: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user