From 7217b833d336d9c581574aa1a7b502686031a9e6 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sat, 18 Sep 2021 00:05:00 +0430 Subject: [PATCH] fix when a source fails to load mangas --- src/screens/manga/SourceMangas.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/screens/manga/SourceMangas.tsx b/src/screens/manga/SourceMangas.tsx index dc878b46..2a232382 100644 --- a/src/screens/manga/SourceMangas.tsx +++ b/src/screens/manga/SourceMangas.tsx @@ -22,9 +22,10 @@ export default function SourceMangas(props: { popular: boolean }) { const [mangas, setMangas] = useState([]); const [hasNextPage, setHasNextPage] = useState(false); const [lastPageNum, setLastPageNum] = useState(1); + const [fetched, setFetched] = useState(false); useEffect(() => { - setTitle('Source'); // title is deligated to `MangaGrid` but we set it here once + setTitle('Source'); // title is later set after a fetch but we set it here once }, []); useEffect(() => { @@ -49,7 +50,7 @@ export default function SourceMangas(props: { popular: boolean }) { client.get(`/api/v1/source/${sourceId}`) .then((response) => response.data) .then((data: ISource) => { - setTitle(data.name); + setTitle(data.displayName); setIsConfigurable(data.isConfigurable); }); }, []); @@ -65,15 +66,20 @@ export default function SourceMangas(props: { popular: boolean }) { title: it.title, thumbnailUrl: it.thumbnailUrl, id: it.id, }))]); setHasNextPage(data.hasNextPage); + setFetched(true); }); }, [lastPageNum]); + let message; + if (fetched) message = 'No manga was found!'; + return ( ); }