mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
add default playaction to play context menu click
This commit is contained in:
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { usePlayer } from '/@/renderer/features/player/context/player-context';
|
import { usePlayer } from '/@/renderer/features/player/context/player-context';
|
||||||
import { useCurrentServerId } from '/@/renderer/store';
|
import { useCurrentServerId, usePlayButtonBehavior } from '/@/renderer/store';
|
||||||
import { ContextMenu } from '/@/shared/components/context-menu/context-menu';
|
import { ContextMenu } from '/@/shared/components/context-menu/context-menu';
|
||||||
import { LibraryItem, Song } from '/@/shared/types/domain-types';
|
import { LibraryItem, Song } from '/@/shared/types/domain-types';
|
||||||
import { Play } from '/@/shared/types/types';
|
import { Play } from '/@/shared/types/types';
|
||||||
@@ -47,6 +47,12 @@ export const PlayAction = ({ ids, itemType, songs }: PlayActionProps) => {
|
|||||||
handlePlay(Play.SHUFFLE);
|
handlePlay(Play.SHUFFLE);
|
||||||
}, [handlePlay]);
|
}, [handlePlay]);
|
||||||
|
|
||||||
|
const playButtonBehavior = usePlayButtonBehavior();
|
||||||
|
|
||||||
|
const defaultPlayAction = useCallback(() => {
|
||||||
|
handlePlay(playButtonBehavior);
|
||||||
|
}, [handlePlay, playButtonBehavior]);
|
||||||
|
|
||||||
if (ids.length === 0) return null;
|
if (ids.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,7 +60,7 @@ export const PlayAction = ({ ids, itemType, songs }: PlayActionProps) => {
|
|||||||
<ContextMenu.SubmenuTarget>
|
<ContextMenu.SubmenuTarget>
|
||||||
<ContextMenu.Item
|
<ContextMenu.Item
|
||||||
leftIcon="mediaPlay"
|
leftIcon="mediaPlay"
|
||||||
onSelect={(e) => e.preventDefault()}
|
onSelect={defaultPlayAction}
|
||||||
rightIcon="arrowRightS"
|
rightIcon="arrowRightS"
|
||||||
>
|
>
|
||||||
{t('player.play', { postProcess: 'sentenceCase' })}
|
{t('player.play', { postProcess: 'sentenceCase' })}
|
||||||
|
|||||||
Reference in New Issue
Block a user