Skip to content

Commit

Permalink
fix sort sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jun 27, 2018
1 parent 92526f5 commit 8bd5990
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/client/lib/cachedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CachedCollection {
listenChangesForLoggedUsersOnly = false,
useSync = true,
useCache = true,
version = 7,
version = 8,
maxCacheTime = 60*60*24*30,
onSyncData = (/* action, record */) => {}
}) {
Expand Down
26 changes: 13 additions & 13 deletions packages/rocketchat-ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ const getLowerCaseNames = (room, nameDefault = '') => {
};
};

// RocketChat.Notifications['onUser']('rooms-changed', );

const mergeSubRoom = (record/*, t*/) => {
const room = Tracker.nonreactive(() => RocketChat.models.Rooms.findOne({ _id: record.rid }));
if (!room) {
return record;
}
record.lastMessage = room.lastMessage;
record.lm = room._updatedAt;
return _.extend(record, getLowerCaseNames(record));
const mergeSubRoom = subscription => {
const room = RocketChat.models.Rooms.findOne(subscription.rid) || { _updatedAt: subscription.ts };
subscription.lastMessage = room.lastMessage;
subscription.lm = room._updatedAt;
return Object.assign(subscription, getLowerCaseNames(subscription));
};

RocketChat.callbacks.add('cachedCollection-received-rooms', (room) => {
const mergeRoomSub = room => {
const sub = RocketChat.models.Subscriptions.findOne({ rid: room._id });
if (!sub) {
return;
return room;
}
const $set = {lastMessage : room.lastMessage, lm: room._updatedAt, ...getLowerCaseNames(room, sub.name)};
RocketChat.models.Subscriptions.update({ rid: room._id }, {$set});
});
return room;
};

RocketChat.callbacks.add('cachedCollection-received-rooms', mergeRoomSub);
RocketChat.callbacks.add('cachedCollection-sync-rooms', mergeRoomSub);
RocketChat.callbacks.add('cachedCollection-loadFromServer-rooms', mergeRoomSub);

RocketChat.callbacks.add('cachedCollection-received-subscriptions', mergeSubRoom);
RocketChat.callbacks.add('cachedCollection-sync-subscriptions', mergeSubRoom);
Expand Down

0 comments on commit 8bd5990

Please sign in to comment.