From d2f68041cba0209957967c47c88508b9229ede0a Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:44:13 +0200 Subject: [PATCH] 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 --- src/components/manga/useRefreshManga.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/manga/useRefreshManga.ts b/src/components/manga/useRefreshManga.ts index 36eb03f5..95a51055 100644 --- a/src/components/manga/useRefreshManga.ts +++ b/src/components/manga/useRefreshManga.ts @@ -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]);