Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Feb 26, 2021
1 parent 630f079 commit 8a605ca
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/lib/methods/helpers/mergeSubscriptionsRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export const merge = (subscription, room) => {
if (room) {
if (room._updatedAt) {
subscription.lastMessage = normalizeMessage(room.lastMessage);
if (serverVersion && lte(coerce(serverVersion), '3.7.0')) {
const updatedAt = room?._updatedAt ? new Date(room._updatedAt) : null;
const lastMessageTs = subscription?.lastMessage?.ts ? new Date(subscription.lastMessage.ts) : null;
subscription.roomUpdatedAt = Math.max(updatedAt, lastMessageTs);
}
subscription.description = room.description;
subscription.topic = room.topic;
subscription.announcement = room.announcement;
Expand All @@ -33,7 +28,11 @@ export const merge = (subscription, room) => {
subscription.usernames = room.usernames;
subscription.uids = room.uids;
}
if (serverVersion && gt(coerce(serverVersion), '3.7.0')) {
if (serverVersion && lte(coerce(serverVersion), '3.7.0')) {
const updatedAt = room?._updatedAt ? new Date(room._updatedAt) : null;
const lastMessageTs = subscription?.lastMessage?.ts ? new Date(subscription.lastMessage.ts) : null;
subscription.roomUpdatedAt = Math.max(updatedAt, lastMessageTs);
} else {
// https://github.com/RocketChat/Rocket.Chat/blob/develop/app/ui-sidenav/client/roomList.js#L180
const lastRoomUpdate = room.lm || subscription.ts || subscription._updatedAt;
subscription.roomUpdatedAt = subscription.lr ? Math.max(new Date(subscription.lr), new Date(lastRoomUpdate)) : lastRoomUpdate;
Expand Down

0 comments on commit 8a605ca

Please sign in to comment.