Add play on double click for song list rows
This commit is contained in:
parent
1f232fa4da
commit
4a64f5fe9b
1 changed files with 15 additions and 0 deletions
|
@ -6,6 +6,7 @@ import type {
|
||||||
GridReadyEvent,
|
GridReadyEvent,
|
||||||
IDatasource,
|
IDatasource,
|
||||||
PaginationChangedEvent,
|
PaginationChangedEvent,
|
||||||
|
RowDoubleClickedEvent,
|
||||||
} from '@ag-grid-community/core';
|
} from '@ag-grid-community/core';
|
||||||
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
||||||
import { Stack } from '@mantine/core';
|
import { Stack } from '@mantine/core';
|
||||||
|
@ -32,6 +33,9 @@ import debounce from 'lodash/debounce';
|
||||||
import { openContextMenu } from '/@/renderer/features/context-menu';
|
import { openContextMenu } from '/@/renderer/features/context-menu';
|
||||||
import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items';
|
import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items';
|
||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
|
import { useHandlePlayQueueAdd } from '/@/renderer/features/player/hooks/use-handle-playqueue-add';
|
||||||
|
import { usePlayButtonBehavior } from '/@/renderer/store/settings.store';
|
||||||
|
import { QueueSong } from '/@/renderer/api/types';
|
||||||
|
|
||||||
interface SongListContentProps {
|
interface SongListContentProps {
|
||||||
tableRef: MutableRefObject<AgGridReactType | null>;
|
tableRef: MutableRefObject<AgGridReactType | null>;
|
||||||
|
@ -45,6 +49,8 @@ export const SongListContent = ({ tableRef }: SongListContentProps) => {
|
||||||
const pagination = useSongTablePagination();
|
const pagination = useSongTablePagination();
|
||||||
const setPagination = useSetSongTablePagination();
|
const setPagination = useSetSongTablePagination();
|
||||||
const setTable = useSetSongTable();
|
const setTable = useSetSongTable();
|
||||||
|
const handlePlayQueueAdd = useHandlePlayQueueAdd();
|
||||||
|
const playButtonBehavior = usePlayButtonBehavior();
|
||||||
|
|
||||||
const isPaginationEnabled = page.display === ListDisplayType.TABLE_PAGINATED;
|
const isPaginationEnabled = page.display === ListDisplayType.TABLE_PAGINATED;
|
||||||
|
|
||||||
|
@ -180,6 +186,14 @@ export const SongListContent = ({ tableRef }: SongListContentProps) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRowDoubleClick = (e: RowDoubleClickedEvent<QueueSong>) => {
|
||||||
|
if (!e.data) return;
|
||||||
|
handlePlayQueueAdd({
|
||||||
|
byData: [e.data],
|
||||||
|
play: playButtonBehavior,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
h="100%"
|
h="100%"
|
||||||
|
@ -221,6 +235,7 @@ export const SongListContent = ({ tableRef }: SongListContentProps) => {
|
||||||
onGridReady={onGridReady}
|
onGridReady={onGridReady}
|
||||||
onGridSizeChanged={handleGridSizeChange}
|
onGridSizeChanged={handleGridSizeChange}
|
||||||
onPaginationChanged={onPaginationChanged}
|
onPaginationChanged={onPaginationChanged}
|
||||||
|
onRowDoubleClicked={handleRowDoubleClick}
|
||||||
/>
|
/>
|
||||||
</VirtualGridAutoSizerContainer>
|
</VirtualGridAutoSizerContainer>
|
||||||
<AnimatePresence
|
<AnimatePresence
|
||||||
|
|
Reference in a new issue