From a95937f2536e25ce5b3988477306f31300956b3f Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 20 May 2023 13:25:10 +0200 Subject: [PATCH] Fix/global search not showing request error (#310) * Show error message in case search request failed In case of an error the message was showing "no mangas found" * [i18n::en] Sort keys alphabetically --- src/i18n/locale/en.json | 17 +++++++++-------- src/screens/SearchAll.tsx | 10 +++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 13762ef671..828b7086ad 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -139,14 +139,14 @@ }, "download": { "queue": { - "label": { - "no_downloads": "No downloads" - }, "error": { "label": { "failed_to_remove": "Could not remove download from queue." } }, + "label": { + "no_downloads": "No downloads" + }, "title": "Download Queue" }, "state": { @@ -280,10 +280,10 @@ "title": "Badges" }, "tab": { - "title": "Tabs", "label": { "show_number_of_items": "Show number of items" - } + }, + "title": "Tabs" } }, "sort": { @@ -384,7 +384,8 @@ "search": { "error": { "label": { - "failed_to_save_settings": "Could not save the default search settings to the server" + "failed_to_save_settings": "Could not save the default search settings to the server", + "source_search_failed": "Could not search source" } }, "label": { @@ -423,10 +424,10 @@ "dark_theme": "Dark theme", "image_cache": "Use image cache", "image_cache_description": "Reduces the data consumption and improves the performance when a already requested image gets requested again", + "language_description": "Feel free to translate the project on", "manga_item_width": "Manga item width", "show_nsfw": "Show NSFW", - "show_nsfw_description": "Hide NSFW extensions and sources", - "language_description": "Feel free to translate the project on" + "show_nsfw_description": "Hide NSFW extensions and sources" }, "server_address": { "dialog": { diff --git a/src/screens/SearchAll.tsx b/src/screens/SearchAll.tsx index bfa096c9f6..3d062b4ebc 100644 --- a/src/screens/SearchAll.tsx +++ b/src/screens/SearchAll.tsx @@ -96,6 +96,7 @@ const SourceSearchPreview = ({ size, setSize, isLoading, + error, } = requestManager.useSourceSearch(id, searchString ?? '', 1, { skipRequest }); const mangas = !isLoading ? searchResult?.[0]?.mangaList ?? [] : []; const noMangasFound = !isLoading && !mangas.length; @@ -108,6 +109,13 @@ const SourceSearchPreview = ({ return null; } + let errorMessage: string | undefined; + if (error) { + errorMessage = t('search.error.label.source_search_failed'); + } else if (noMangasFound) { + errorMessage = t('manga.error.label.no_mangas_found'); + } + return ( <> @@ -124,7 +132,7 @@ const SourceSearchPreview = ({ setLastPageNum={setSize} horizontal noFaces - message={noMangasFound ? t('manga.error.label.no_mangas_found') : undefined} + message={errorMessage} inLibraryIndicator />