From 129e6171a57dd5b17357c5687891a80a1292cd1b Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 5 May 2024 00:50:15 +0200 Subject: [PATCH] Handle request error in Updates --- src/screens/Updates.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/screens/Updates.tsx b/src/screens/Updates.tsx index 5dc33d76..d6b35a19 100644 --- a/src/screens/Updates.tsx +++ b/src/screens/Updates.tsx @@ -32,6 +32,7 @@ import { StyledGroupItemWrapper } from '@/components/virtuoso/StyledGroupItemWra import { Mangas } from '@/lib/data/Mangas.ts'; import { SpinnerImage } from '@/components/util/SpinnerImage.tsx'; import { dateTimeFormatter, epochToDate, getDateString } from '@/util/date.ts'; +import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts'; const groupByDate = (updates: TChapter[]): [date: string, items: number][] => { if (!updates.length) { @@ -55,7 +56,9 @@ export const Updates: React.FC = () => { const { data: chapterUpdateData, loading: isLoading, + error, fetchMore, + refetch, } = requestManager.useGetRecentlyUpdatedChapters(undefined, { fetchPolicy: 'cache-and-network', notifyOnNetworkStatusChange: true, @@ -112,6 +115,16 @@ export const Updates: React.FC = () => { fetchMore({ variables: { offset: updateEntries.length } }); }, [hasNextPage, endCursor]); + if (error) { + return ( + refetch().catch(defaultPromiseErrorHandler('Updates::refetch'))} + /> + ); + } + if (!isLoading && updateEntries.length === 0) { return ; }