mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-20 07:37:26 -05:00
23 lines
632 B
TypeScript
23 lines
632 B
TypeScript
import { useKey } from 'rooks';
|
|
import type { ExplorerItem } from '@sd/client';
|
|
import { dialogManager } from '@sd/ui';
|
|
import DeleteDialog from '~/app/$libraryId/Explorer/FilePath/DeleteDialog';
|
|
|
|
export const useKeyDeleteFile = (selectedItems: Set<ExplorerItem>, locationId?: number | null) => {
|
|
return useKey('Delete', (e) => {
|
|
e.preventDefault();
|
|
|
|
if (!locationId) return;
|
|
|
|
const pathIds: number[] = [];
|
|
|
|
for (const item of selectedItems) {
|
|
if (item.type === 'Path') pathIds.push(item.item.id);
|
|
}
|
|
|
|
dialogManager.create((dp) => (
|
|
<DeleteDialog {...dp} locationId={locationId} pathIds={pathIds} />
|
|
));
|
|
});
|
|
};
|