From 1a2c31badfc9683cfe552577894efdb3dfe26353 Mon Sep 17 00:00:00 2001 From: Rankin Zheng Date: Wed, 19 Jul 2023 16:15:26 +0800 Subject: [PATCH] Refactor deleteMessage handler and remove debugger statement - Updated the 'deleteChatMessage' handler to directly access the hash from the message object. - Removed a debugger statement from the 'deleteMessage.fulfilled' case in chatSlice. --- src/views/chatSlice.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/views/chatSlice.ts b/src/views/chatSlice.ts index 9b064da..f5e51ab 100644 --- a/src/views/chatSlice.ts +++ b/src/views/chatSlice.ts @@ -24,9 +24,9 @@ export const deleteMessage = createAsyncThunk<{ hash }, { hash }>('chat/deleteMe return new Promise((resolve, reject) => { try { messageUtil.sendMessage({ command: 'deleteChatMessage', hash: hash }); - messageUtil.registerHandler('deletedChatMessage', (rhash: any) => { + messageUtil.registerHandler('deletedChatMessage', (message) => { resolve({ - hash: rhash + hash: message.hash }); }); } catch (e) { @@ -162,7 +162,6 @@ export const chatSlice = createSlice({ .addCase(deleteMessage.fulfilled, (state, action) => { const { hash } = action.payload; const index = state.messages.findIndex((item: any) => item.hash === hash); - debugger if (index > -1) { state.messages.splice(index); }