Skip to content

Commit

Permalink
[FIX] Last message not updating after message delete if show deleted …
Browse files Browse the repository at this point in the history
…status is on (#12350)
  • Loading branch information
sampaiodiego authored Oct 17, 2018
1 parent 2ea96a5 commit ee3c78d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/functions/deleteMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RocketChat.deleteMessage = function(message, user) {
if (RocketChat.settings.get('Store_Last_Message')) {
const room = RocketChat.models.Rooms.findOneById(message.rid, { fields: { lastMessage: 1 } });
if (!room.lastMessage || room.lastMessage._id === message._id) {
RocketChat.models.Rooms.resetLastMessageById(message.rid);
RocketChat.models.Rooms.resetLastMessageById(message.rid, message._id);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ class ModelRooms extends RocketChat.models._Base {
return this.update(query, update);
}

resetLastMessageById(_id) {
resetLastMessageById(_id, messageId) {
const query = { _id };
const lastMessage = RocketChat.models.Messages.getLastVisibleMessageSentWithNoTypeByRoomId(_id);
const lastMessage = RocketChat.models.Messages.getLastVisibleMessageSentWithNoTypeByRoomId(_id, messageId);

const update = lastMessage ? {
$set: {
Expand Down

0 comments on commit ee3c78d

Please sign in to comment.