From c84b3b24792d2aee1d02587b375d8715308fe7db Mon Sep 17 00:00:00 2001 From: subham103 Date: Sat, 15 Feb 2020 01:12:33 +0530 Subject: [PATCH] [FIX] sort channel directory listing by latest message --- app/ui/client/views/app/directory.html | 4 ++-- server/methods/browseChannels.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/ui/client/views/app/directory.html b/app/ui/client/views/app/directory.html index f2990d38bf8d6..a9c729f6b159c 100644 --- a/app/ui/client/views/app/directory.html +++ b/app/ui/client/views/app/directory.html @@ -45,8 +45,8 @@
{{_ "Users"}} {{> icon icon=(sortIcon 'usersCount')}}
{{#if showLastMessage}} - -
{{_ "Last_Message"}}
+ +
{{_ "Last_Message"}} {{> icon icon=(sortIcon 'lastMessage')}}
{{/if}} diff --git a/server/methods/browseChannels.js b/server/methods/browseChannels.js index 25dd440b665a8..ad0e44936846e 100644 --- a/server/methods/browseChannels.js +++ b/server/methods/browseChannels.js @@ -15,6 +15,10 @@ const sortChannels = function(field, direction) { return { ts: direction === 'asc' ? 1 : -1, }; + case 'lastMessage': + return { + 'lastMessage.ts': direction === 'asc' ? 1 : -1, + }; default: return { [field]: direction === 'asc' ? 1 : -1, @@ -47,7 +51,7 @@ Meteor.methods({ return; } - if (!['name', 'createdAt', 'usersCount', ...type === 'channels' ? ['usernames'] : [], ...type === 'users' ? ['username'] : []].includes(sortBy)) { + if (!['name', 'createdAt', 'usersCount', ...type === 'channels' ? ['usernames', 'lastMessage'] : [], ...type === 'users' ? ['username'] : []].includes(sortBy)) { return; }