mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
add delete hotkey to playqueue
This commit is contained in:
@@ -26,6 +26,8 @@ import { Flex } from '/@/shared/components/flex/flex';
|
|||||||
import { LoadingOverlay } from '/@/shared/components/loading-overlay/loading-overlay';
|
import { LoadingOverlay } from '/@/shared/components/loading-overlay/loading-overlay';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
import { useDebouncedValue } from '/@/shared/hooks/use-debounced-value';
|
import { useDebouncedValue } from '/@/shared/hooks/use-debounced-value';
|
||||||
|
import { useFocusWithin } from '/@/shared/hooks/use-focus-within';
|
||||||
|
import { useHotkeys } from '/@/shared/hooks/use-hotkeys';
|
||||||
import { useMergedRef } from '/@/shared/hooks/use-merged-ref';
|
import { useMergedRef } from '/@/shared/hooks/use-merged-ref';
|
||||||
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
||||||
import { DragTarget } from '/@/shared/types/drag-and-drop';
|
import { DragTarget } from '/@/shared/types/drag-and-drop';
|
||||||
@@ -140,8 +142,29 @@ export const PlayQueue = forwardRef<ItemListHandle, QueueProps>(({ listKey, sear
|
|||||||
const currentSong = usePlayerSong();
|
const currentSong = usePlayerSong();
|
||||||
const currentSongUniqueId = currentSong?._uniqueId;
|
const currentSongUniqueId = currentSong?._uniqueId;
|
||||||
|
|
||||||
|
const { focused, ref: containerFocusRef } = useFocusWithin();
|
||||||
|
const player = usePlayer();
|
||||||
|
|
||||||
|
useHotkeys([
|
||||||
|
[
|
||||||
|
'delete',
|
||||||
|
() => {
|
||||||
|
if (focused) {
|
||||||
|
const selectedItems =
|
||||||
|
tableRef.current?.internalState.getSelected() as QueueSong[];
|
||||||
|
|
||||||
|
if (!selectedItems || selectedItems.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.clearSelected(selectedItems);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container} key={containerKey}>
|
<div className={styles.container} key={containerKey} ref={containerFocusRef}>
|
||||||
<LoadingOverlay pos="absolute" visible={isFetching} />
|
<LoadingOverlay pos="absolute" visible={isFetching} />
|
||||||
<ItemTableList
|
<ItemTableList
|
||||||
activeRowId={currentSongUniqueId}
|
activeRowId={currentSongUniqueId}
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
(items: QueueSong[]) => {
|
(items: QueueSong[]) => {
|
||||||
logFn.debug(logMsg[LogCategory.PLAYER].clearSelected, {
|
logFn.debug(logMsg[LogCategory.PLAYER].clearSelected, {
|
||||||
category: LogCategory.PLAYER,
|
category: LogCategory.PLAYER,
|
||||||
meta: { items },
|
meta: { items: items.length },
|
||||||
});
|
});
|
||||||
|
|
||||||
storeActions.clearSelected(items);
|
storeActions.clearSelected(items);
|
||||||
|
|||||||
Reference in New Issue
Block a user