Skip to content

Commit

Permalink
fix: editing a message not working (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dun-sin authored Dec 2, 2024
1 parent 32bbf35 commit f5a1d0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions client/src/components/Chat/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const MessageList = ({
return decryptedMessages.find((object) => object.id === replyTo);
}

console.log(decryptedMessages);

return (
decryptedMessages &&
decryptedMessages.map(
Expand Down
8 changes: 6 additions & 2 deletions server/sockets/editMessage.js
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -8,7 +8,8 @@ module.exports = (socket) => {
{ id: messageId, chatId, newMessage, oldMessage },
messageWasEditedSuccessfully
) => {
const user = getActiveUser({
try {
const user = getActiveUser({
socketId: socket.id,
});

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

0 comments on commit f5a1d0b

Please sign in to comment.