Fix refreshing manga during migration search

This commit is contained in:
schroda
2026-04-23 19:34:43 +02:00
parent 2ae613885d
commit 0ed2e7c193
5 changed files with 67 additions and 14 deletions

View File

@@ -13,23 +13,23 @@ import { baseCleanup } from '@/base/utils/Strings.ts';
export const useRefreshManga = (mangaId: string) => {
const [fetchingOnline, setFetchingOnline] = useState(false);
const [error, setError] = useState(null);
const [error, setError] = useState<unknown>(null);
const handleRefresh = useCallback(async () => {
setFetchingOnline(true);
setError(null);
await Promise.all([
requestManager.getMangaFetch(mangaId, { awaitRefetchQueries: true }).response,
requestManager.getMangaChaptersFetch(mangaId, { awaitRefetchQueries: true }).response,
])
.catch((e) => {
if (CombinedGraphQLErrors.is(e) && baseCleanup(e.message) === 'no chapters found') {
return;
}
setError(e);
})
.finally(() => setFetchingOnline(false));
try {
await requestManager.refreshManga(mangaId, { awaitRefetchQueries: true }).response;
} catch (e) {
if (CombinedGraphQLErrors.is(e) && baseCleanup(e.message) === 'no chapters found') {
return;
}
setError(e);
} finally {
setFetchingOnline(false);
}
}, [mangaId]);
return [handleRefresh, { loading: fetchingOnline, error }] as const;

View File

@@ -698,9 +698,18 @@ export class MigrationManager {
throw new Error(signal.reason);
}
const updatedMatch = await requestManager.getMangaFetch(match.id).response;
return (async () => {
try {
const updatedMatch = await requestManager.refreshManga(match.id, { awaitRefetchQueries: true })
.response;
return updatedMatch.data?.fetchManga?.manga ?? match;
return updatedMatch.data?.fetchManga?.manga ?? match;
} catch (e) {
// ignore
}
return match;
})();
});
const updatedMatches = await Promise.all(matchUpdatePromises);