Handle request error in Updates
This commit is contained in:
@@ -32,6 +32,7 @@ import { StyledGroupItemWrapper } from '@/components/virtuoso/StyledGroupItemWra
|
|||||||
import { Mangas } from '@/lib/data/Mangas.ts';
|
import { Mangas } from '@/lib/data/Mangas.ts';
|
||||||
import { SpinnerImage } from '@/components/util/SpinnerImage.tsx';
|
import { SpinnerImage } from '@/components/util/SpinnerImage.tsx';
|
||||||
import { dateTimeFormatter, epochToDate, getDateString } from '@/util/date.ts';
|
import { dateTimeFormatter, epochToDate, getDateString } from '@/util/date.ts';
|
||||||
|
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||||
|
|
||||||
const groupByDate = (updates: TChapter[]): [date: string, items: number][] => {
|
const groupByDate = (updates: TChapter[]): [date: string, items: number][] => {
|
||||||
if (!updates.length) {
|
if (!updates.length) {
|
||||||
@@ -55,7 +56,9 @@ export const Updates: React.FC = () => {
|
|||||||
const {
|
const {
|
||||||
data: chapterUpdateData,
|
data: chapterUpdateData,
|
||||||
loading: isLoading,
|
loading: isLoading,
|
||||||
|
error,
|
||||||
fetchMore,
|
fetchMore,
|
||||||
|
refetch,
|
||||||
} = requestManager.useGetRecentlyUpdatedChapters(undefined, {
|
} = requestManager.useGetRecentlyUpdatedChapters(undefined, {
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
@@ -112,6 +115,16 @@ export const Updates: React.FC = () => {
|
|||||||
fetchMore({ variables: { offset: updateEntries.length } });
|
fetchMore({ variables: { offset: updateEntries.length } });
|
||||||
}, [hasNextPage, endCursor]);
|
}, [hasNextPage, endCursor]);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<EmptyViewAbsoluteCentered
|
||||||
|
message={t('global.error.label.failed_to_load_data')}
|
||||||
|
messageExtra={error.message}
|
||||||
|
retry={() => refetch().catch(defaultPromiseErrorHandler('Updates::refetch'))}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLoading && updateEntries.length === 0) {
|
if (!isLoading && updateEntries.length === 0) {
|
||||||
return <EmptyViewAbsoluteCentered message={t('updates.error.label.no_updates_available')} />;
|
return <EmptyViewAbsoluteCentered message={t('updates.error.label.no_updates_available')} />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user