From f5a1d0b64ac9e617c3d3d86918faaa9e7c064ca8 Mon Sep 17 00:00:00 2001 From: Dunsin <78784850+Dun-sin@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:33:03 +0100 Subject: [PATCH] fix: editing a message not working (#734) --- client/src/components/Chat/MessageList.jsx | 2 -- server/sockets/editMessage.js | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/components/Chat/MessageList.jsx b/client/src/components/Chat/MessageList.jsx index fbbf617b..23dd6047 100644 --- a/client/src/components/Chat/MessageList.jsx +++ b/client/src/components/Chat/MessageList.jsx @@ -42,8 +42,6 @@ const MessageList = ({ return decryptedMessages.find((object) => object.id === replyTo); } - console.log(decryptedMessages); - return ( decryptedMessages && decryptedMessages.map( diff --git a/server/sockets/editMessage.js b/server/sockets/editMessage.js index a8b94844..7ff2e37a 100644 --- a/server/sockets/editMessage.js +++ b/server/sockets/editMessage.js @@ -1,5 +1,5 @@ const { NEW_EVENT_EDIT_MESSAGE } = require('../../constants.json'); -const { getActiveUser, editMessage } = require('../utils/lib'); +const { getActiveUser, editMessage, isMessageEditableOrDeletable } = require('../utils/lib'); module.exports = (socket) => { socket.on( @@ -8,7 +8,8 @@ module.exports = (socket) => { { id: messageId, chatId, newMessage, oldMessage }, messageWasEditedSuccessfully ) => { - const user = getActiveUser({ + try { + const user = getActiveUser({ socketId: socket.id, }); @@ -30,6 +31,9 @@ module.exports = (socket) => { }); socket.broadcast.to(chatId).emit(NEW_EVENT_EDIT_MESSAGE, messageEdited); messageWasEditedSuccessfully(messageEdited); + } catch (error) { + console.log('Error while editing Message: ', error) + } } ); };