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

@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Migration**) Sort entries in search/execution page by title
- (**Migration**) Prevent a manual selected match from getting automatically overwritten by a new-found match
- (**Migration**) Abort active search when selecting a match through the manual search
- (**Migration**) Sort unselected matched entries by 1. their latest chapter, 2. their source priority, 3. their title
### Fixed

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],
);