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.
This commit is contained in:
Rankin Zheng 2023-07-19 16:15:26 +08:00
parent 8a5ecbc001
commit 1a2c31badf

View File

@ -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);
}