From 99316f4bd5f887f5762aca194df64a2a63a8a06d Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Fri, 29 Jan 2021 14:25:18 +0330 Subject: [PATCH] revert react changes --- webUI/react/src/components/MangaCard.tsx | 18 ++-------------- webUI/react/src/components/MangaGrid.tsx | 27 +++--------------------- webUI/react/src/screens/MangaList.tsx | 1 - webUI/react/src/screens/SearchSingle.tsx | 1 - 4 files changed, 5 insertions(+), 42 deletions(-) diff --git a/webUI/react/src/components/MangaCard.tsx b/webUI/react/src/components/MangaCard.tsx index 2182af2..12ae32a 100644 --- a/webUI/react/src/components/MangaCard.tsx +++ b/webUI/react/src/components/MangaCard.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import React, { useEffect } from 'react'; +import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Card from '@material-ui/core/Card'; import CardActionArea from '@material-ui/core/CardActionArea'; @@ -43,29 +43,15 @@ const useStyles = makeStyles({ interface IProps { manga: IManga - setMangaThumbnailUrl: (thumbnailUrl:string) => void } const MangaCard = React.forwardRef((props: IProps, ref) => { const { manga: { id, title, thumbnailUrl, - }, setMangaThumbnailUrl, + }, } = props; const classes = useStyles(); - console.log(`${title} has ${thumbnailUrl}`); - - if (thumbnailUrl === null || thumbnailUrl.length === 0) { - useEffect(() => { - fetch(`http://127.0.0.1:4567/api/v1/manga/${id}/`) - .then((response) => response.json()) - .then((data: IManga) => { - setMangaThumbnailUrl(data.thumbnailUrl); - }); - }, - []); - } - return ( diff --git a/webUI/react/src/components/MangaGrid.tsx b/webUI/react/src/components/MangaGrid.tsx index 19bb9b4..ac2d752 100644 --- a/webUI/react/src/components/MangaGrid.tsx +++ b/webUI/react/src/components/MangaGrid.tsx @@ -12,21 +12,15 @@ interface IProps{ hasNextPage: boolean lastPageNum: number setLastPageNum: (lastPageNum: number) => void - setMangas: (mangas: IManga[]) => void } export default function MangaGrid(props: IProps) { const { - mangas, message, hasNextPage, lastPageNum, setLastPageNum, setMangas, + mangas, message, hasNextPage, lastPageNum, setLastPageNum, } = props; let mapped; const lastManga = useRef(); - function setMangaThumbnailUrl(index: number, thumbnailUrl: string) { - mangas[index].thumbnailUrl = thumbnailUrl; - setMangas(mangas); - } - const scrollHandler = () => { if (lastManga.current) { const rect = lastManga.current.getBoundingClientRect(); @@ -47,24 +41,9 @@ export default function MangaGrid(props: IProps) { } else { mapped = mangas.map((it, idx) => { if (idx === mangas.length - 1) { - return ( - setMangaThumbnailUrl(idx, thumbnailUrl) - } - /> - ); + return ; } - return ( - setMangaThumbnailUrl(idx, thumbnailUrl) - } - /> - ); + return ; }); } diff --git a/webUI/react/src/screens/MangaList.tsx b/webUI/react/src/screens/MangaList.tsx index 6a1e25f..78dd7dd 100644 --- a/webUI/react/src/screens/MangaList.tsx +++ b/webUI/react/src/screens/MangaList.tsx @@ -37,7 +37,6 @@ export default function MangaList(props: { popular: boolean }) { return (