Abort active migration search on manual search match selection
This commit is contained in:
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- (**Migration**) Sort destination source selection by same order as browse source page
|
||||
- (**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
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -97,7 +97,8 @@ export class MigrationManager {
|
||||
|
||||
private static mangaProcessQueue = pLimit(MAX_MANGAS_IN_PARALLEL);
|
||||
private static parallelSourcesQueue: LimitFunction | undefined;
|
||||
private static queueBySource = new Map<string, LimitFunction>();
|
||||
private static queueBySource = new Map<SourceIdInfo['id'], LimitFunction>();
|
||||
private static searchAbortControllerByManga = new Map<MangaIdInfo['id'], AbortController>();
|
||||
|
||||
private static abortAndResetAbortController(reason: unknown): void {
|
||||
MigrationManager.abortController?.abort(reason);
|
||||
@@ -617,7 +618,16 @@ export class MigrationManager {
|
||||
draft.entries[mangaId].manualMatches = [...draft.entries[mangaId].manualMatches, match];
|
||||
}
|
||||
|
||||
const isSearching = ![
|
||||
MigrationEntryStatus.SEARCH_FAILED,
|
||||
MigrationEntryStatus.SEARCH_COMPLETE,
|
||||
].includes(entry.status);
|
||||
|
||||
MigrationManager.selectMatch(mangaId, match.id, match.sourceId, true);
|
||||
|
||||
if (isSearching) {
|
||||
MigrationManager.searchAbortControllerByManga.get(mangaId)?.abort('Manual match selected');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -705,10 +715,6 @@ export class MigrationManager {
|
||||
throw new Error(signal.reason);
|
||||
}
|
||||
|
||||
if (signal.aborted) {
|
||||
throw new Error(signal.reason);
|
||||
}
|
||||
|
||||
if (!selectHighestChapterNumberSource && MigrationManager.hasHigherSourcePriorityMatch(mangaId, sourceId)) {
|
||||
throw new Error('Entry already has a selected match from a higher priority source');
|
||||
}
|
||||
@@ -803,6 +809,9 @@ export class MigrationManager {
|
||||
const searchController = new AbortController();
|
||||
const signal = AbortSignal.any([mainSignal, searchController.signal]);
|
||||
|
||||
MigrationManager.searchAbortControllerByManga.get(mangaId)?.abort('search');
|
||||
MigrationManager.searchAbortControllerByManga.set(mangaId, searchController);
|
||||
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
@@ -973,6 +982,8 @@ export class MigrationManager {
|
||||
draft.searchProgress.completed += 1;
|
||||
draft.searchProgress.failed += 1;
|
||||
});
|
||||
} finally {
|
||||
MigrationManager.searchAbortControllerByManga.delete(mangaId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user