Skip to content

Commit

Permalink
Merge pull request RocketChat#317 from Shailesh351/sb_fix_lm
Browse files Browse the repository at this point in the history
Fix sortBy Activity in Sidebar
  • Loading branch information
ear-dev committed Jul 7, 2020
2 parents bc6b0a5 + c86f828 commit 89d601b
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 @@ -180,4 +180,5 @@ import './v179';
import './v180';
import './v181';
import './v182';
import './v183';
import './xrun';
21 changes: 21 additions & 0 deletions server/startup/migrations/v183.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: 183,
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 89d601b

Please sign in to comment.