add default playaction to play context menu click

This commit is contained in:
jeffvli
2025-11-18 00:46:28 -08:00
parent 0493cc0c9d
commit 278c669a18
@@ -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' })}