Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
CORE-9 Potential fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Volkov committed May 28, 2021
1 parent 6c13edf commit 9b0bb54
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import { ChatSubscription, Rooms, Users, Subscriptions } from '../../models';
import { UiTextContext, getUserPreference, roomTypes } from '../../utils';
import { settings } from '../../settings';

const updateLastMessage = (subscription) => {
const room = Rooms.findOne(subscription.rid);
if (room && room.lastMessage) {
Subscriptions.update({
rid: room._id,
}, {
$set: {
lastMessage: room.lastMessage,
lm: room._updatedAt,
},
});
}
};

Template.roomList.helpers({
rooms() {
/*
Expand Down Expand Up @@ -100,8 +114,15 @@ Template.roomList.helpers({
query.f = { $ne: favoritesEnabled };
}
}
return ChatSubscription.find(query, { sort });

const subscriptions = ChatSubscription.find(query, { sort }).fetch();
subscriptions
.filter((s) => s.t === 'd' && !s.lastMessage)
.forEach((s) => setTimeout(() => updateLastMessage(s), 1000));

return subscriptions;
},

isLivechat() {
return this.identifier === 'l';
},
Expand Down

0 comments on commit 9b0bb54

Please sign in to comment.