From 978562900e2355d8a4e92f57b899ff154c77ce28 Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Fri, 22 Nov 2024 17:56:22 +0100 Subject: [PATCH] refactor: minor updates --- api/src/chat/controllers/block.controller.ts | 2 +- .../components/visual-editor/v2/Diagrams.tsx | 23 ++----------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/api/src/chat/controllers/block.controller.ts b/api/src/chat/controllers/block.controller.ts index 3cc9dc9..0cdc057 100644 --- a/api/src/chat/controllers/block.controller.ts +++ b/api/src/chat/controllers/block.controller.ts @@ -332,7 +332,7 @@ export class BlockController extends BaseController< @CsrfCheck(true) @Delete('') @HttpCode(204) - async deleteMany(@Body('ids') ids: string[]): Promise { + async deleteBlocksByIds(@Body('ids') ids: string[]): Promise { if (!ids || ids.length === 0) { throw new BadRequestException('No IDs provided for deletion.'); } diff --git a/frontend/src/components/visual-editor/v2/Diagrams.tsx b/frontend/src/components/visual-editor/v2/Diagrams.tsx index 681c5ea..3c44e79 100644 --- a/frontend/src/components/visual-editor/v2/Diagrams.tsx +++ b/frontend/src/components/visual-editor/v2/Diagrams.tsx @@ -372,14 +372,7 @@ const Diagrams = () => { }, ); }; - const handleBlockDeletion = async (blockIds: string[]) => { - if (blockIds.length > 1) { - await deleteMultipleBlocks(blockIds); - } else { - await deleteSingleBlock(blockIds[0]); - } - }; - const deleteMultipleBlocks = async (blockIds: string[]) => { + const handleBlocksDeletion = async (blockIds: string[]) => { await deleteBlocks(blockIds, { onSuccess: () => { blockIds.forEach((blockId) => { @@ -393,18 +386,6 @@ const Diagrams = () => { }, }); }; - const deleteSingleBlock = async (blockId: string) => { - const block = getBlockFromCache(blockId); - - await deleteBlock(blockId, { - onSuccess() { - if (block) { - updateLinkedBlocks(block, [blockId]); - deleteCachedBlock(blockId); - } - }, - }); - }; const getLinkedBlockIds = (block: IBlock): string[] => [ ...(block?.nextBlocks || []), ...(block?.previousBlocks || []), @@ -481,7 +462,7 @@ const Diagrams = () => { if (isLink) { await handleLinkDeletion(ids[0]); } else { - await handleBlockDeletion(ids); + await handleBlocksDeletion(ids); } cleanupAfterDeletion();