Fix refreshing manga during migration search
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user