Files
spacedrive/interface/hooks/useKeyDeleteFile.tsx
Utku fd8c0f87b3 [ENG-1067] Update phosphor to new package & update sort imports (#1330)
* ianvs > trivago

* @phosphor-icons/react > phosphor-react
2023-09-11 15:26:44 +00:00

24 lines
633 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} />
));
});
};