From 0a95bf57b628d53839d1083298fa0668c9d9b18c Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 17 May 2026 13:52:19 +0200 Subject: [PATCH] Update sorting of bulk migration other matches 1. Latest chapter 2. Source priority 3. Title --- CHANGELOG.md | 1 + src/features/migration/MigrationManager.ts | 6 ++++++ .../migration-entry/MigrationEntry.tsx | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 128b5ace..4184b747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/features/migration/MigrationManager.ts b/src/features/migration/MigrationManager.ts index d2860601..77deb225 100644 --- a/src/features/migration/MigrationManager.ts +++ b/src/features/migration/MigrationManager.ts @@ -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'], diff --git a/src/features/migration/components/migration-entry/MigrationEntry.tsx b/src/features/migration/components/migration-entry/MigrationEntry.tsx index 0ad96d45..ccbf0416 100644 --- a/src/features/migration/components/migration-entry/MigrationEntry.tsx +++ b/src/features/migration/components/migration-entry/MigrationEntry.tsx @@ -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], );