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
This commit is contained in:
schroda
2023-05-20 13:25:10 +02:00
committed by GitHub
parent 474e568a05
commit a95937f253
2 changed files with 18 additions and 9 deletions

View File

@@ -139,14 +139,14 @@
}, },
"download": { "download": {
"queue": { "queue": {
"label": {
"no_downloads": "No downloads"
},
"error": { "error": {
"label": { "label": {
"failed_to_remove": "Could not remove download from queue." "failed_to_remove": "Could not remove download from queue."
} }
}, },
"label": {
"no_downloads": "No downloads"
},
"title": "Download Queue" "title": "Download Queue"
}, },
"state": { "state": {
@@ -280,10 +280,10 @@
"title": "Badges" "title": "Badges"
}, },
"tab": { "tab": {
"title": "Tabs",
"label": { "label": {
"show_number_of_items": "Show number of items" "show_number_of_items": "Show number of items"
} },
"title": "Tabs"
} }
}, },
"sort": { "sort": {
@@ -384,7 +384,8 @@
"search": { "search": {
"error": { "error": {
"label": { "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": { "label": {
@@ -423,10 +424,10 @@
"dark_theme": "Dark theme", "dark_theme": "Dark theme",
"image_cache": "Use image cache", "image_cache": "Use image cache",
"image_cache_description": "Reduces the data consumption and improves the performance when a already requested image gets requested again", "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", "manga_item_width": "Manga item width",
"show_nsfw": "Show NSFW", "show_nsfw": "Show NSFW",
"show_nsfw_description": "Hide NSFW extensions and sources", "show_nsfw_description": "Hide NSFW extensions and sources"
"language_description": "Feel free to translate the project on"
}, },
"server_address": { "server_address": {
"dialog": { "dialog": {

View File

@@ -96,6 +96,7 @@ const SourceSearchPreview = ({
size, size,
setSize, setSize,
isLoading, isLoading,
error,
} = requestManager.useSourceSearch(id, searchString ?? '', 1, { skipRequest }); } = requestManager.useSourceSearch(id, searchString ?? '', 1, { skipRequest });
const mangas = !isLoading ? searchResult?.[0]?.mangaList ?? [] : []; const mangas = !isLoading ? searchResult?.[0]?.mangaList ?? [] : [];
const noMangasFound = !isLoading && !mangas.length; const noMangasFound = !isLoading && !mangas.length;
@@ -108,6 +109,13 @@ const SourceSearchPreview = ({
return null; 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 ( return (
<> <>
<Card sx={{ margin: '10px' }}> <Card sx={{ margin: '10px' }}>
@@ -124,7 +132,7 @@ const SourceSearchPreview = ({
setLastPageNum={setSize} setLastPageNum={setSize}
horizontal horizontal
noFaces noFaces
message={noMangasFound ? t('manga.error.label.no_mangas_found') : undefined} message={errorMessage}
inLibraryIndicator inLibraryIndicator
/> />
</> </>