From 9b99f3f3540fe1a189ee6074a1a53142b56036fc Mon Sep 17 00:00:00 2001 From: Montassar Ghanmy Date: Wed, 24 Jul 2024 16:01:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20permanent=20trash=20delete?= =?UTF-8?q?=20(#629)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/features/drive/hooks/use-drive-actions.tsx | 6 ++++-- .../client/body/drive/modals/confirm-delete/index.tsx | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx index f56c794e..cbb7eb3d 100644 --- a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx +++ b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx @@ -111,9 +111,11 @@ export const useDriveActions = () => { ); const remove = useCallback( - async (id: string, parentId: string) => { + async (id: string | string[], parentId: string) => { try { - await DriveApiClient.remove(companyId, id); + if (Array.isArray(id)) { + await Promise.all(id.map(i => DriveApiClient.remove(companyId, i))); + } else await DriveApiClient.remove(companyId, id); await refresh(parentId || '', true); await getQuota(); } catch (e) { diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/confirm-delete/index.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/confirm-delete/index.tsx index d31ad1c2..5a31d570 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/confirm-delete/index.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/confirm-delete/index.tsx @@ -41,7 +41,7 @@ const ConfirmDeleteModalContent = ({ items }: { items: DriveItem[] }) => { const [loading, setLoading] = useState(false); const [state, setState] = useRecoilState(ConfirmDeleteModalAtom); const [, setSelected] = useRecoilState(DriveItemSelectedList); - const { viewId } = RouterServices.getStateFromRoute(); + const { dirId, viewId } = RouterServices.getStateFromRoute(); useEffect(() => { refresh(items[0].id); @@ -65,9 +65,8 @@ const ConfirmDeleteModalContent = ({ items }: { items: DriveItem[] }) => { loading={loading} onClick={async () => { setLoading(true); - for (const item of items) { - await remove(item.id, viewId || ""); - } + const ids = items.map((item) => item.id); + await remove(ids, dirId || viewId || ""); setLoading(false); setSelected({}); setState({ ...state, open: false });