From f17c612d1000ed0084926ac0541826f6ba60c5a7 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sat, 18 Sep 2021 00:00:12 +0430 Subject: [PATCH 1/5] fix viewing page number when the string is long --- src/components/manga/reader/PageNumber.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/manga/reader/PageNumber.tsx b/src/components/manga/reader/PageNumber.tsx index 1e91e8d8..45933bca 100644 --- a/src/components/manga/reader/PageNumber.tsx +++ b/src/components/manga/reader/PageNumber.tsx @@ -14,7 +14,7 @@ const useStyles = (settings: IReaderSettings) => makeStyles({ position: 'fixed', bottom: '50px', right: settings.staticNav ? 'calc((100vw - 325px)/2)' : 'calc((100vw - 25px)/2)', - width: '50px', + padding: '2px', textAlign: 'center', backgroundColor: 'rgba(0, 0, 0, 0.3)', borderRadius: '10px', From a7a444320944802d3512247bce6c27f4cdf955ab Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sat, 18 Sep 2021 00:03:42 +0430 Subject: [PATCH 2/5] show proper display name for source --- src/components/manga/MangaDetails.tsx | 4 ++-- src/typings.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/manga/MangaDetails.tsx b/src/components/manga/MangaDetails.tsx index 58064c0b..b9ede79f 100644 --- a/src/components/manga/MangaDetails.tsx +++ b/src/components/manga/MangaDetails.tsx @@ -121,8 +121,8 @@ interface IProps{ } function getSourceName(source: ISource) { - if (source.name !== null) { - return `${source.name} (${source.lang.toLocaleUpperCase()})`; + if (source.displayName !== null) { + return source.displayName; } return source.id; } diff --git a/src/typings.d.ts b/src/typings.d.ts index 2ad6f657..ba9164d8 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -25,9 +25,9 @@ interface ISource { lang: string iconUrl: string supportsLatest: boolean - history: any isConfigurable: boolean isNsfw: boolean + displayName: string } interface IMangaCard { From 2de37687ae257cc41e5d5d86b1a7a2e3f940b03f Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sat, 18 Sep 2021 00:04:09 +0430 Subject: [PATCH 3/5] fail gracefully when a thumbnail has errors --- src/components/SpinnerImage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/SpinnerImage.tsx b/src/components/SpinnerImage.tsx index 58f4b1a4..ed7e0a95 100644 --- a/src/components/SpinnerImage.tsx +++ b/src/components/SpinnerImage.tsx @@ -35,20 +35,28 @@ export default function SpinnerImage(props: IProps) { onImageLoad?.(); }; + img.onerror = () => { + setImagsrc('Not Found'); + }; + return () => { img.onload = null; + img.onerror = null; }; }, [src]); if (imageSrc.length === 0) { return ( - //
); } + if (imageSrc === 'Not Found') { + return
; + } + return ( Date: Sat, 18 Sep 2021 00:05:00 +0430 Subject: [PATCH 4/5] 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 ( ); } From b47dcbeff736c5a4d1a4a5c3f67764fd0bc31a96 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sat, 18 Sep 2021 00:48:48 +0430 Subject: [PATCH 5/5] play favorites with Local source --- src/util/language.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/language.tsx b/src/util/language.tsx index 5290145e..1a88e403 100644 --- a/src/util/language.tsx +++ b/src/util/language.tsx @@ -12,6 +12,8 @@ export const ISOLanguages = [ { code: 'other', name: 'other langs?', nativeName: 'Other' }, + { code: 'localsourcelang', name: 'Local source', nativeName: 'Other' }, + // full list: https://github.com/meikidd/iso-639-1/blob/master/src/data.js { code: 'en', name: 'English', nativeName: 'English' }, { code: 'ca', name: 'Catalan; Valencian', nativeName: 'CatalĂ ' }, @@ -95,6 +97,7 @@ export function defualtLangs() { return [ // todo: infer this from the browser 'en', + 'localSourceLang', ]; } @@ -105,5 +108,8 @@ export const langSortCmp = (a: string, b: string) => { if (a === 'en') return -1; if (b === 'en') return 1; + if (a === 'localSourceLang') return 1; + if (b === 'localSourceLang') return -1; + return aLang > bLang ? 1 : -1; };