From a0f6dea91a7beec7531145a6a2b949e20cbcfd4b Mon Sep 17 00:00:00 2001 From: SandipBajracharya Date: Tue, 3 Feb 2026 17:01:20 +0545 Subject: [PATCH] fix(OUT-3055): optimistic channel sync remove after delete modal confirmation - [x] remove the extra state that stores the delete channelId - [x] directly pass the channelId to the function --- src/features/sync/hooks/useTable.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/features/sync/hooks/useTable.ts b/src/features/sync/hooks/useTable.ts index 2b59f19..dc2b33d 100644 --- a/src/features/sync/hooks/useTable.ts +++ b/src/features/sync/hooks/useTable.ts @@ -227,16 +227,15 @@ export const useRemoveChannelSync = () => { const { user } = useAuthContext() const { setUserChannel, tempMapList } = useUserChannel() - const [removeId, setRemoveId] = useState() const { setDialogAttributes, toggleDialog } = useDialogContext() - const removeChannelSync = async () => { + const removeChannelSync = async (channelSyncId?: string) => { toggleDialog(false) const localMapList = tempMapList setUserChannel((prev) => ({ ...prev, - tempMapList: prev.tempMapList.filter((item) => item.id !== removeId), + tempMapList: prev.tempMapList.filter((item) => item.id !== channelSyncId), })) try { @@ -246,7 +245,7 @@ export const useRemoveChannelSync = () => { {}, { body: JSON.stringify({ - channelSyncId: removeId, + channelSyncId, }), }, ) @@ -260,14 +259,12 @@ export const useRemoveChannelSync = () => { } const openConfirmDialog = (id?: string) => { - setRemoveId(id) - setDialogAttributes((prev) => ({ ...prev, isOpen: true, title: 'Remove channel sync', description: 'Are you sure you want to remove this channel sync?', - onConfirm: () => removeChannelSync(), + onConfirm: () => removeChannelSync(id), })) }