Skip to content

Commit

Permalink
[NEW] Sort the Omnichannel Chat list according to the user preferences (
Browse files Browse the repository at this point in the history
#16437)

* Fix the order of the Omnichannel chats list, keeping the items sorted by activity.

* Remove invalid console.log.

* Sort the Omnichannel chat list according the user preference.

* Remove unnecessary extra parenthesis.
  • Loading branch information
renatobecker authored Feb 3, 2020
1 parent 90aea1f commit 38fc6ec
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions app/livechat/client/views/sideNav/livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,16 @@ Template.livechat.helpers({
open: true,
};

const user = Users.findOne(Meteor.userId(), {
fields: { 'settings.preferences.sidebarShowUnread': 1 },
});
const user = Meteor.userId();

if (getUserPreference(user, 'sidebarShowUnread')) {
query.alert = { $ne: true };
}

return ChatSubscription.find(query, {
sort: {
t: 1,
fname: 1,
},
});
const sortBy = getUserPreference(user, 'sidebarSortby');
const sort = sortBy === 'activity' ? { _updatedAt: - 1 } : { fname: 1 };

return ChatSubscription.find(query, { sort });
},

inquiries() {
Expand Down

0 comments on commit 38fc6ec

Please sign in to comment.