From dc70e803b44625da7d96739e678024ed44a28abe Mon Sep 17 00:00:00 2001 From: Marcos Spessatto Defendi Date: Tue, 20 Nov 2018 22:24:27 -0200 Subject: [PATCH] [IMPROVE] Improve unreads and unreadsFrom response, prevent it to be equal null (#12563) * Improve unreads and unreadsFrom response, prevent it to be equal null * Add timestamp or last seen in groups.counter Co-Authored-By: MarcosSpessatto --- packages/rocketchat-api/server/v1/groups.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-api/server/v1/groups.js b/packages/rocketchat-api/server/v1/groups.js index 5a125fb01d31..fc5430c1f6ce 100644 --- a/packages/rocketchat-api/server/v1/groups.js +++ b/packages/rocketchat-api/server/v1/groups.js @@ -151,10 +151,8 @@ RocketChat.API.v1.addRoute('groups.counters', { authRequired: true }, { const lm = room.lm ? room.lm : room._updatedAt; if (typeof subscription !== 'undefined' && subscription.open) { - if (subscription.ls) { - unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls, lm); - unreadsFrom = subscription.ls; - } + unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, (subscription.ls || subscription.ts), lm); + unreadsFrom = subscription.ls || subscription.ts; userMentions = subscription.userMentions; joined = true; }