Handle missing chapters when refreshing manga

The server throws an error in case the source returns an empty chapter list.
However, this is not an error and thus should not be handled as one
This commit is contained in:
schroda
2024-08-14 14:44:13 +02:00
parent 782148a10e
commit d2f68041cb

View File

@@ -7,7 +7,9 @@
*/
import { useCallback, useState } from 'react';
import { ApolloError } from '@apollo/client';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { baseCleanup } from '@/lib/data/Strings.ts';
export const useRefreshManga = (mangaId: string) => {
const [fetchingOnline, setFetchingOnline] = useState(false);
@@ -20,7 +22,13 @@ export const useRefreshManga = (mangaId: string) => {
requestManager.getMangaFetch(mangaId, { awaitRefetchQueries: true }).response,
requestManager.getMangaChaptersFetch(mangaId, { awaitRefetchQueries: true }).response,
])
.catch((e) => setError(e))
.catch((e) => {
if (e instanceof ApolloError && baseCleanup(e.message) === 'no chapters found') {
return;
}
setError(e);
})
.finally(() => setFetchingOnline(false));
}, [mangaId]);