mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 04:51:06 +02:00
replace remaining legacy playqueue add functions
This commit is contained in:
@@ -3,7 +3,7 @@ import { Fragment, useCallback, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { generatePath, useNavigate } from 'react-router';
|
||||
|
||||
import { usePlayQueueAdd } from '/@/renderer/features/player/hooks/use-playqueue-add';
|
||||
import { usePlayer } from '/@/renderer/features/player/context/player-context';
|
||||
import { searchQueries } from '/@/renderer/features/search/api/search-api';
|
||||
import { Command, CommandPalettePages } from '/@/renderer/features/search/components/command';
|
||||
import { CommandItemSelectable } from '/@/renderer/features/search/components/command-item-selectable';
|
||||
@@ -70,8 +70,6 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||
const showArtistGroup = isHome && Boolean(query && data && data?.albumArtists?.length > 0);
|
||||
const showTrackGroup = isHome && Boolean(query && data && data?.songs?.length > 0);
|
||||
|
||||
const handlePlayQueueAdd = usePlayQueueAdd();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
{...modalProps}
|
||||
@@ -169,7 +167,6 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||
>
|
||||
{({ isHighlighted }) => (
|
||||
<LibraryCommandItem
|
||||
handlePlayQueueAdd={handlePlayQueueAdd}
|
||||
id={album.id}
|
||||
imageUrl={album.imageUrl}
|
||||
isHighlighted={isHighlighted}
|
||||
@@ -203,7 +200,6 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||
{({ isHighlighted }) => (
|
||||
<LibraryCommandItem
|
||||
disabled={artist?.albumCount === 0}
|
||||
handlePlayQueueAdd={handlePlayQueueAdd}
|
||||
id={artist.id}
|
||||
imageUrl={artist.imageUrl}
|
||||
isHighlighted={isHighlighted}
|
||||
@@ -241,7 +237,6 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||
>
|
||||
{({ isHighlighted }) => (
|
||||
<LibraryCommandItem
|
||||
handlePlayQueueAdd={handlePlayQueueAdd}
|
||||
id={song.id}
|
||||
imageUrl={song.imageUrl}
|
||||
isHighlighted={isHighlighted}
|
||||
|
||||
@@ -3,17 +3,18 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import styles from './library-command-item.module.css';
|
||||
|
||||
import { usePlayer } from '/@/renderer/features/player/context/player-context';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { ActionIcon } from '/@/shared/components/action-icon/action-icon';
|
||||
import { Flex } from '/@/shared/components/flex/flex';
|
||||
import { Group } from '/@/shared/components/group/group';
|
||||
import { Image } from '/@/shared/components/image/image';
|
||||
import { Text } from '/@/shared/components/text/text';
|
||||
import { LibraryItem } from '/@/shared/types/domain-types';
|
||||
import { Play, PlayQueueAddOptions } from '/@/shared/types/types';
|
||||
import { Play } from '/@/shared/types/types';
|
||||
|
||||
interface LibraryCommandItemProps {
|
||||
disabled?: boolean;
|
||||
handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void;
|
||||
id: string;
|
||||
imageUrl: null | string;
|
||||
isHighlighted?: boolean;
|
||||
@@ -24,7 +25,6 @@ interface LibraryCommandItemProps {
|
||||
|
||||
export const LibraryCommandItem = ({
|
||||
disabled,
|
||||
handlePlayQueueAdd,
|
||||
id,
|
||||
imageUrl,
|
||||
isHighlighted,
|
||||
@@ -33,20 +33,17 @@ export const LibraryCommandItem = ({
|
||||
title,
|
||||
}: LibraryCommandItemProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { addToQueueByFetch } = usePlayer();
|
||||
const server = useCurrentServer();
|
||||
|
||||
const handlePlay = useCallback(
|
||||
(e: SyntheticEvent, id: string, playType: Play) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handlePlayQueueAdd?.({
|
||||
byItemType: {
|
||||
id: [id],
|
||||
type: itemType,
|
||||
},
|
||||
playType,
|
||||
});
|
||||
if (!server?.id) return;
|
||||
addToQueueByFetch(server.id, [id], itemType, playType);
|
||||
},
|
||||
[handlePlayQueueAdd, itemType],
|
||||
[addToQueueByFetch, itemType, server?.id],
|
||||
);
|
||||
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user