Skip to content

Commit

Permalink
Merge pull request RocketChat#324 from Shailesh351/sb_fix_sort
Browse files Browse the repository at this point in the history
[Upstream Demo] Fix sortBy Activity in Sidebar
  • Loading branch information
ear-dev authored Jul 7, 2020
2 parents 8ca5c06 + 99f63b9 commit 2d09ef2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const getLowerCaseNames = (room, nameDefault = '', fnameDefault = '') => {
const mergeSubRoom = (subscription) => {
const room = Rooms.findOne(subscription.rid) || { _updatedAt: subscription.ts };
subscription.lastMessage = room.lastMessage;
subscription.lm = room._updatedAt;
subscription.lm = (room.lastMessage && room.lastMessage.ts) || room._updatedAt;
subscription.streamingOptions = room.streamingOptions;
return Object.assign(subscription, getLowerCaseNames(subscription));
};
Expand All @@ -160,7 +160,7 @@ const mergeRoomSub = (room) => {
}, {
$set: {
lastMessage: room.lastMessage,
lm: room._updatedAt,
lm: (room.lastMessage && room.lastMessage.ts) || room._updatedAt,
streamingOptions: room.streamingOptions,
...getLowerCaseNames(room, sub.name, sub.fname),
},
Expand Down
1 change: 1 addition & 0 deletions server/startup/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@ import './v186';
import './v187';
import './v188';
import './v189';
import './v190';
import './xrun';
21 changes: 21 additions & 0 deletions server/startup/migrations/v190.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Migrations } from '../../../app/migrations';
import { Subscriptions, Rooms } from '../../../app/models';

Migrations.add({
version: 190,
up() {
const subscriptions = Subscriptions.find({}).fetch();

subscriptions.forEach((subscription) => {
const room = Rooms.findOneById(subscription.rid);

Subscriptions.update({
_id: subscription._id,
}, {
$set: {
lm: (room.lastMessage && room.lastMessage.ts) || subscription._updatedAt,
},
});
});
},
});

0 comments on commit 2d09ef2

Please sign in to comment.