Update sorting of bulk migration other matches

1. Latest chapter
2. Source priority
3. Title
This commit is contained in:
schroda
2026-05-17 13:52:19 +02:00
parent 6564484540
commit 0a95bf57b6
3 changed files with 23 additions and 1 deletions

View File

@@ -672,6 +672,12 @@ export class MigrationManager {
return destinationSourceIds;
}
public static getSourcePriority(mangaSourceId: SourceIdInfo['id'], sourceId: SourceIdInfo['id']): number {
const destinationSourceIds = MigrationManager.getDestinationSourceIds(mangaSourceId);
return destinationSourceIds.indexOf(sourceId);
}
private static getHigherPrioritySourceIds(
mangaSourceId: SourceIdInfo['id'],
destSourceId: SourceIdInfo['id'],

View File

@@ -212,7 +212,22 @@ export const MigrationEntry = memo(
() =>
entry.searchMatches
.filter((searchMatch) => searchMatch.id !== entry.selectedMatchMangaId)
.sort((a, b) => (b.latestChapterNumber ?? 0) - (a.latestChapterNumber ?? 0)),
.sort((a, b) => {
const sortByLatestChapter = (b.latestChapterNumber ?? 0) - (a.latestChapterNumber ?? 0);
if (sortByLatestChapter) {
return sortByLatestChapter;
}
const aSourcePriority = MigrationManager.getSourcePriority(entry.sourceId, a.sourceId);
const bSourcePriority = MigrationManager.getSourcePriority(entry.sourceId, b.sourceId);
const sortBySourcePriority = bSourcePriority - aSourcePriority;
if (sortBySourcePriority) {
return sortBySourcePriority;
}
return a.title.localeCompare(b.title);
}),
[entry.searchMatches, entry.selectedMatchMangaId],
);