From 891d6f4165a18656e5fc6e040ead218f8675dde0 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:54:56 +0100 Subject: [PATCH] Fix/manga migration opening search twice (#586) * Update "MenuItem" props * Navigate to manga migration only once * Remove disabling migrate button on manga refresh too much copy&paste --- .../chapter/ChapterActionMenuItems.tsx | 12 +++++----- src/components/manga/MangaActionMenuItems.tsx | 22 +++++-------------- src/components/manga/MangaToolbarMenu.tsx | 2 +- src/components/menu/MenuItem.tsx | 10 ++++----- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/components/chapter/ChapterActionMenuItems.tsx b/src/components/chapter/ChapterActionMenuItems.tsx index 79de034b..48ea9e83 100644 --- a/src/components/chapter/ChapterActionMenuItems.tsx +++ b/src/components/chapter/ChapterActionMenuItems.tsx @@ -128,7 +128,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(canBeDownloaded) && ( performAction('download', downloadableChapters)} title={getMenuItemTitle('download', downloadableChapters.length)} /> @@ -136,7 +136,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(isDownloaded) && ( performAction('delete', downloadedChapters)} title={getMenuItemTitle('delete', downloadedChapters.length)} /> @@ -144,7 +144,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(!isBookmarked) && ( performAction('bookmark', unbookmarkedChapters)} title={getMenuItemTitle('bookmark', unbookmarkedChapters.length)} /> @@ -152,7 +152,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(isBookmarked) && ( performAction('unbookmark', bookmarkedChapters)} title={getMenuItemTitle('unbookmark', bookmarkedChapters.length)} /> @@ -160,7 +160,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(!isRead) && ( performAction('mark_as_read', unreadChapters)} title={getMenuItemTitle('mark_as_read', unreadChapters.length)} /> @@ -168,7 +168,7 @@ export const ChapterActionMenuItems = ({ {shouldShowMenuItem(isRead) && ( performAction('mark_as_unread', readChapters)} title={getMenuItemTitle('mark_as_unread', readChapters.length)} /> diff --git a/src/components/manga/MangaActionMenuItems.tsx b/src/components/manga/MangaActionMenuItems.tsx index 50fec2d6..f0fcebf2 100644 --- a/src/components/manga/MangaActionMenuItems.tsx +++ b/src/components/manga/MangaActionMenuItems.tsx @@ -16,7 +16,7 @@ import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'; import Label from '@mui/icons-material/Label'; import { useMemo, useState } from 'react'; import SyncAltIcon from '@mui/icons-material/SyncAlt'; -import { Link, useNavigate } from 'react-router-dom'; +import { Link } from 'react-router-dom'; import { TManga } from '@/typings.ts'; import { actionToTranslationKey, MangaAction, MangaDownloadInfo, Mangas, MangaUnreadInfo } from '@/lib/data/Mangas.ts'; import { SelectableCollectionReturnType } from '@/components/collection/useSelectableCollection.ts'; @@ -51,8 +51,6 @@ export const MangaActionMenuItems = ({ }: Props) => { const { t } = useTranslation(); - const navigate = useNavigate(); - const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false); const isSingleMode = !!manga; @@ -104,7 +102,7 @@ export const MangaActionMenuItems = ({ {shouldShowMenuItem(!isFullyDownloaded) && ( performAction('download', downloadableMangas)} title={getMenuItemTitle('download', downloadableMangas.length)} /> @@ -112,7 +110,7 @@ export const MangaActionMenuItems = ({ {shouldShowMenuItem(hasDownloadedChapters) && ( performAction('delete', downloadedMangas)} title={getMenuItemTitle('delete', downloadedMangas.length)} /> @@ -120,7 +118,7 @@ export const MangaActionMenuItems = ({ {shouldShowMenuItem(hasUnreadChapters) && ( performAction('mark_as_read', unreadMangas)} title={getMenuItemTitle('mark_as_read', unreadMangas.length)} /> @@ -128,7 +126,7 @@ export const MangaActionMenuItems = ({ {shouldShowMenuItem(hasReadChapters) && ( performAction('mark_as_unread', readMangas)} title={getMenuItemTitle('mark_as_unread', readMangas.length)} /> @@ -139,15 +137,7 @@ export const MangaActionMenuItems = ({ state={{ mangaTitle: manga?.title }} style={{ textDecoration: 'none', color: 'inherit' }} > - - navigate( - `/migrate/source/${manga?.source?.id}/manga/${manga?.id}/search?query=${manga?.title}`, - ) - } - Icon={SyncAltIcon} - title={getMenuItemTitle('migrate', selectedMangas.length)} - /> + )} { state={{ mangaTitle: manga.title }} style={{ textDecoration: 'none', color: 'inherit' }} > - + diff --git a/src/components/menu/MenuItem.tsx b/src/components/menu/MenuItem.tsx index ce734f31..d1de6c17 100644 --- a/src/components/menu/MenuItem.tsx +++ b/src/components/menu/MenuItem.tsx @@ -6,19 +6,17 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { ListItemIcon, ListItemText, MenuItem as MuiMenuItem } from '@mui/material'; +import { ListItemIcon, ListItemText, MenuItem as MuiMenuItem, MenuItemProps } from '@mui/material'; import { OverridableComponent } from '@mui/material/OverridableComponent'; import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon'; -interface IProps { +interface IProps extends MenuItemProps { title: string; Icon: OverridableComponent & { muiName: string }; - onClick: () => void; - isDisabled?: boolean; } -export const MenuItem = ({ onClick, title, Icon, isDisabled }: IProps) => ( - +export const MenuItem = ({ title, Icon, ...menuItemProps }: IProps) => ( +