From 7f27e3b745b4e798791d2dcf72b3a33320bbdf79 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Thu, 9 Sep 2021 22:19:33 +0430 Subject: [PATCH] fix double redirect issue --- src/components/manga/SourceCard.tsx | 149 ++++++++++++++-------------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/src/components/manga/SourceCard.tsx b/src/components/manga/SourceCard.tsx index 60ad37a2..180c71ef 100644 --- a/src/components/manga/SourceCard.tsx +++ b/src/components/manga/SourceCard.tsx @@ -6,11 +6,10 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React from 'react'; -import { useTheme } from '@mui/material/styles'; import makeStyles from '@mui/styles/makeStyles'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; -import { Link, useHistory } from 'react-router-dom'; +import { useHistory } from 'react-router-dom'; import SearchIcon from '@mui/icons-material/Search'; import Button from '@mui/material/Button'; import IconButton from '@mui/material/IconButton'; @@ -76,96 +75,96 @@ interface IProps { export default function SourceCard(props: IProps) { const { source: { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - id, name, lang, iconUrl, supportsLatest, isConfigurable, + id, name, lang, iconUrl, supportsLatest, }, } = props; - const theme = useTheme(); const history = useHistory(); const [serverAddress] = useLocalStorage('serverBaseURL', ''); const classes = useStyles(); - return ( - - - + const redirectTo = (e: any, to: string) => { + history.push(to); -
- -
- - {name} - - - {langCodeToName(lang)} - -
+ // prevent parent tags from getting the event + e.stopPropagation(); + }; + + return ( + redirectTo(e, `/sources/${id}/popular/`)} + > + + +
+ +
+ + {name} + + + {langCodeToName(lang)} +
-
-
+
+
+
+ redirectTo(e, `/sources/${id}/search/`)} + size="large" + edge="end" + > + + + {supportsLatest && ( history.push(`/sources/${id}/search/`)} + onClick={(e) => redirectTo(e, `/sources/${id}/latest/`)} size="large" - edge="end" > - - {supportsLatest && ( - history.push(`/sources/${id}/latest/`)} - size="large" - > - - - )} -
-
- - {supportsLatest && ( - - )} - -
+ )}
- - +
+ + {supportsLatest && ( + + )} + +
+
+ ); }