Skip to content

Node.js based forum software built for the modern web

move load on restore

Barış Soner Uşaklı887333478a36
diff --git a/src/messaging/delete.js b/src/messaging/delete.js
index c8070f7740..0363481e42 100644
--- a/src/messaging/delete.js
+++ b/src/messaging/delete.js
@@ -14,12 +14,11 @@ module.exports = function (Messaging) {
}
await Messaging.setMessageField(mid, 'deleted', state);
-
- const messages = await Messaging.getMessagesData([mid], uid, roomId, true);
const ioRoom = sockets.in(`chat_room_${roomId}`);
if (state === 1 && ioRoom) {
ioRoom.emit('event:chats.delete', mid);
} else if (state === 0 && ioRoom) {
+ const messages = await Messaging.getMessagesData([mid], uid, roomId, true);
ioRoom.emit('event:chats.restore', messages[0]);
}
}