diff --git a/apps/web/src/api/buster_rest/chats/queryRequests.ts b/apps/web/src/api/buster_rest/chats/queryRequests.ts index 9ddaf2feb..11f8038f1 100644 --- a/apps/web/src/api/buster_rest/chats/queryRequests.ts +++ b/apps/web/src/api/buster_rest/chats/queryRequests.ts @@ -216,23 +216,33 @@ export const useDeleteChat = () => { }) => { const method = () => deleteChat(data); if (useConfirmModal) { - return await openConfirmModal({ + const result = await openConfirmModal({ title: 'Delete Chat', content: 'Are you sure you want to delete this chat?', onOk: method }); + return { + wasCancelled: result === undefined, + result + }; } - return method(); + const result = await method(); + return { + wasCancelled: false, + result + }; } ); return useMutation({ mutationFn, - onSuccess() { - queryClient.invalidateQueries({ - queryKey: chatQueryKeys.chatsGetList().queryKey, - refetchType: 'all' - }); + onSuccess(data) { + if (!data.wasCancelled) { + queryClient.invalidateQueries({ + queryKey: chatQueryKeys.chatsGetList().queryKey, + refetchType: 'all' + }); + } } }); }; diff --git a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx index 743567177..3a63220d6 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx @@ -46,9 +46,11 @@ export const ChatContainerHeaderDropdown: React.FC<{ deleteChat( { data: [chatId] }, { - onSuccess: () => { - onChangePage({ route: BusterRoutes.APP_CHAT }); - openSuccessMessage('Chat deleted'); + onSuccess: (data) => { + if (!data.wasCancelled) { + onChangePage({ route: BusterRoutes.APP_CHAT }); + openSuccessMessage('Chat deleted'); + } } } )