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
This commit is contained in:
@@ -128,7 +128,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(canBeDownloaded) && (
|
{shouldShowMenuItem(canBeDownloaded) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Download}
|
Icon={Download}
|
||||||
isDisabled={isMenuItemDisabled(!downloadableChapters.length)}
|
disabled={isMenuItemDisabled(!downloadableChapters.length)}
|
||||||
onClick={() => performAction('download', downloadableChapters)}
|
onClick={() => performAction('download', downloadableChapters)}
|
||||||
title={getMenuItemTitle('download', downloadableChapters.length)}
|
title={getMenuItemTitle('download', downloadableChapters.length)}
|
||||||
/>
|
/>
|
||||||
@@ -136,7 +136,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(isDownloaded) && (
|
{shouldShowMenuItem(isDownloaded) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Delete}
|
Icon={Delete}
|
||||||
isDisabled={isMenuItemDisabled(!downloadedChapters.length)}
|
disabled={isMenuItemDisabled(!downloadedChapters.length)}
|
||||||
onClick={() => performAction('delete', downloadedChapters)}
|
onClick={() => performAction('delete', downloadedChapters)}
|
||||||
title={getMenuItemTitle('delete', downloadedChapters.length)}
|
title={getMenuItemTitle('delete', downloadedChapters.length)}
|
||||||
/>
|
/>
|
||||||
@@ -144,7 +144,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(!isBookmarked) && (
|
{shouldShowMenuItem(!isBookmarked) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={BookmarkAdd}
|
Icon={BookmarkAdd}
|
||||||
isDisabled={isMenuItemDisabled(!unbookmarkedChapters.length)}
|
disabled={isMenuItemDisabled(!unbookmarkedChapters.length)}
|
||||||
onClick={() => performAction('bookmark', unbookmarkedChapters)}
|
onClick={() => performAction('bookmark', unbookmarkedChapters)}
|
||||||
title={getMenuItemTitle('bookmark', unbookmarkedChapters.length)}
|
title={getMenuItemTitle('bookmark', unbookmarkedChapters.length)}
|
||||||
/>
|
/>
|
||||||
@@ -152,7 +152,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(isBookmarked) && (
|
{shouldShowMenuItem(isBookmarked) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={BookmarkRemove}
|
Icon={BookmarkRemove}
|
||||||
isDisabled={isMenuItemDisabled(!bookmarkedChapters.length)}
|
disabled={isMenuItemDisabled(!bookmarkedChapters.length)}
|
||||||
onClick={() => performAction('unbookmark', bookmarkedChapters)}
|
onClick={() => performAction('unbookmark', bookmarkedChapters)}
|
||||||
title={getMenuItemTitle('unbookmark', bookmarkedChapters.length)}
|
title={getMenuItemTitle('unbookmark', bookmarkedChapters.length)}
|
||||||
/>
|
/>
|
||||||
@@ -160,7 +160,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(!isRead) && (
|
{shouldShowMenuItem(!isRead) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Done}
|
Icon={Done}
|
||||||
isDisabled={isMenuItemDisabled(!unreadChapters.length)}
|
disabled={isMenuItemDisabled(!unreadChapters.length)}
|
||||||
onClick={() => performAction('mark_as_read', unreadChapters)}
|
onClick={() => performAction('mark_as_read', unreadChapters)}
|
||||||
title={getMenuItemTitle('mark_as_read', unreadChapters.length)}
|
title={getMenuItemTitle('mark_as_read', unreadChapters.length)}
|
||||||
/>
|
/>
|
||||||
@@ -168,7 +168,7 @@ export const ChapterActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(isRead) && (
|
{shouldShowMenuItem(isRead) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={RemoveDone}
|
Icon={RemoveDone}
|
||||||
isDisabled={isMenuItemDisabled(!readChapters.length)}
|
disabled={isMenuItemDisabled(!readChapters.length)}
|
||||||
onClick={() => performAction('mark_as_unread', readChapters)}
|
onClick={() => performAction('mark_as_unread', readChapters)}
|
||||||
title={getMenuItemTitle('mark_as_unread', readChapters.length)}
|
title={getMenuItemTitle('mark_as_unread', readChapters.length)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
|
|||||||
import Label from '@mui/icons-material/Label';
|
import Label from '@mui/icons-material/Label';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import SyncAltIcon from '@mui/icons-material/SyncAlt';
|
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 { TManga } from '@/typings.ts';
|
||||||
import { actionToTranslationKey, MangaAction, MangaDownloadInfo, Mangas, MangaUnreadInfo } from '@/lib/data/Mangas.ts';
|
import { actionToTranslationKey, MangaAction, MangaDownloadInfo, Mangas, MangaUnreadInfo } from '@/lib/data/Mangas.ts';
|
||||||
import { SelectableCollectionReturnType } from '@/components/collection/useSelectableCollection.ts';
|
import { SelectableCollectionReturnType } from '@/components/collection/useSelectableCollection.ts';
|
||||||
@@ -51,8 +51,6 @@ export const MangaActionMenuItems = ({
|
|||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false);
|
const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false);
|
||||||
|
|
||||||
const isSingleMode = !!manga;
|
const isSingleMode = !!manga;
|
||||||
@@ -104,7 +102,7 @@ export const MangaActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(!isFullyDownloaded) && (
|
{shouldShowMenuItem(!isFullyDownloaded) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Download}
|
Icon={Download}
|
||||||
isDisabled={isMenuItemDisabled(!downloadableMangas.length)}
|
disabled={isMenuItemDisabled(!downloadableMangas.length)}
|
||||||
onClick={() => performAction('download', downloadableMangas)}
|
onClick={() => performAction('download', downloadableMangas)}
|
||||||
title={getMenuItemTitle('download', downloadableMangas.length)}
|
title={getMenuItemTitle('download', downloadableMangas.length)}
|
||||||
/>
|
/>
|
||||||
@@ -112,7 +110,7 @@ export const MangaActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(hasDownloadedChapters) && (
|
{shouldShowMenuItem(hasDownloadedChapters) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Delete}
|
Icon={Delete}
|
||||||
isDisabled={isMenuItemDisabled(!downloadedMangas.length)}
|
disabled={isMenuItemDisabled(!downloadedMangas.length)}
|
||||||
onClick={() => performAction('delete', downloadedMangas)}
|
onClick={() => performAction('delete', downloadedMangas)}
|
||||||
title={getMenuItemTitle('delete', downloadedMangas.length)}
|
title={getMenuItemTitle('delete', downloadedMangas.length)}
|
||||||
/>
|
/>
|
||||||
@@ -120,7 +118,7 @@ export const MangaActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(hasUnreadChapters) && (
|
{shouldShowMenuItem(hasUnreadChapters) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={Done}
|
Icon={Done}
|
||||||
isDisabled={isMenuItemDisabled(!unreadMangas.length)}
|
disabled={isMenuItemDisabled(!unreadMangas.length)}
|
||||||
onClick={() => performAction('mark_as_read', unreadMangas)}
|
onClick={() => performAction('mark_as_read', unreadMangas)}
|
||||||
title={getMenuItemTitle('mark_as_read', unreadMangas.length)}
|
title={getMenuItemTitle('mark_as_read', unreadMangas.length)}
|
||||||
/>
|
/>
|
||||||
@@ -128,7 +126,7 @@ export const MangaActionMenuItems = ({
|
|||||||
{shouldShowMenuItem(hasReadChapters) && (
|
{shouldShowMenuItem(hasReadChapters) && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Icon={RemoveDone}
|
Icon={RemoveDone}
|
||||||
isDisabled={isMenuItemDisabled(!readMangas.length)}
|
disabled={isMenuItemDisabled(!readMangas.length)}
|
||||||
onClick={() => performAction('mark_as_unread', readMangas)}
|
onClick={() => performAction('mark_as_unread', readMangas)}
|
||||||
title={getMenuItemTitle('mark_as_unread', readMangas.length)}
|
title={getMenuItemTitle('mark_as_unread', readMangas.length)}
|
||||||
/>
|
/>
|
||||||
@@ -139,15 +137,7 @@ export const MangaActionMenuItems = ({
|
|||||||
state={{ mangaTitle: manga?.title }}
|
state={{ mangaTitle: manga?.title }}
|
||||||
style={{ textDecoration: 'none', color: 'inherit' }}
|
style={{ textDecoration: 'none', color: 'inherit' }}
|
||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem Icon={SyncAltIcon} title={getMenuItemTitle('migrate', selectedMangas.length)} />
|
||||||
onClick={() =>
|
|
||||||
navigate(
|
|
||||||
`/migrate/source/${manga?.source?.id}/manga/${manga?.id}/search?query=${manga?.title}`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Icon={SyncAltIcon}
|
|
||||||
title={getMenuItemTitle('migrate', selectedMangas.length)}
|
|
||||||
/>
|
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const MangaToolbarMenu = ({ manga, onRefresh, refreshing }: IProps) => {
|
|||||||
state={{ mangaTitle: manga.title }}
|
state={{ mangaTitle: manga.title }}
|
||||||
style={{ textDecoration: 'none', color: 'inherit' }}
|
style={{ textDecoration: 'none', color: 'inherit' }}
|
||||||
>
|
>
|
||||||
<IconButton disabled={refreshing}>
|
<IconButton>
|
||||||
<SyncAltIcon />
|
<SyncAltIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -6,19 +6,17 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* 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 { OverridableComponent } from '@mui/material/OverridableComponent';
|
||||||
import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon';
|
import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps extends MenuItemProps {
|
||||||
title: string;
|
title: string;
|
||||||
Icon: OverridableComponent<SvgIconTypeMap> & { muiName: string };
|
Icon: OverridableComponent<SvgIconTypeMap> & { muiName: string };
|
||||||
onClick: () => void;
|
|
||||||
isDisabled?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MenuItem = ({ onClick, title, Icon, isDisabled }: IProps) => (
|
export const MenuItem = ({ title, Icon, ...menuItemProps }: IProps) => (
|
||||||
<MuiMenuItem onClick={onClick} disabled={isDisabled}>
|
<MuiMenuItem {...menuItemProps}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<Icon fontSize="small" />
|
<Icon fontSize="small" />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
|
|||||||
Reference in New Issue
Block a user