From bcccbda00c69f48ee2da73163fed7974282fe11a Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:26:33 +0200 Subject: [PATCH] Add retry option to SearchAll error message --- src/screens/SearchAll.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/screens/SearchAll.tsx b/src/screens/SearchAll.tsx index 675a9fa0..7b386310 100644 --- a/src/screens/SearchAll.tsx +++ b/src/screens/SearchAll.tsx @@ -25,6 +25,7 @@ import { useDebounce } from '@/util/useDebounce.ts'; import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx'; import { MangaCardProps } from '@/components/manga/MangaCard.types.tsx'; import { EmptyView } from '@/components/util/EmptyView'; +import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts'; type SourceLoadingState = { isLoading: boolean; hasResults: boolean; emptySearch: boolean }; type SourceToLoadingStateMap = Map; @@ -103,7 +104,7 @@ const SourceSearchPreview = React.memo( const { t } = useTranslation(); const { id, displayName, lang } = source; - const [, results] = requestManager.useSourceSearch(id, searchString ?? '', undefined, 1, { + const [refetch, results] = requestManager.useSourceSearch(id, searchString ?? '', undefined, 1, { skipRequest: !searchString, addAbortSignal: true, }); @@ -147,7 +148,20 @@ const SourceSearchPreview = React.memo( {errorMessage ? ( - + + refetch(1).catch( + defaultPromiseErrorHandler(`SourceSearchPreview(${source.id})::refetch`), + ) + : undefined + } + /> ) : (