diff --git a/packages/rocketchat-ui/client/views/app/directory.js b/packages/rocketchat-ui/client/views/app/directory.js index 1f37772074901..9f65e546d25dd 100644 --- a/packages/rocketchat-ui/client/views/app/directory.js +++ b/packages/rocketchat-ui/client/views/app/directory.js @@ -14,7 +14,7 @@ function directorySearch(config, cb) { if (config.type === 'channels') { return { name: result.name, - users: result.usernames.length, + users: (result.usernames ? result.usernames.length : result.usersCount) || 0, createdAt: timeAgo(result.ts), lastMessage: result.lastMessage && timeAgo(result.lastMessage.ts), description: result.description, diff --git a/server/methods/browseChannels.js b/server/methods/browseChannels.js index 3cb4338f49295..6f8be8edf325f 100644 --- a/server/methods/browseChannels.js +++ b/server/methods/browseChannels.js @@ -56,19 +56,23 @@ Meteor.methods({ return; } return { - results: RocketChat.models.Rooms.findByNameAndType(regex, 'c', { - ...options, - sort, - fields: { - description: 1, - topic: 1, - name: 1, - lastMessage: 1, - ts: 1, - archived: 1, - usernames: 1 - } - }).fetch(), + results: RocketChat.models.Rooms.findByNameAndType( + regex, + 'c', + { + ...options, + sort, + fields: { + description: 1, + topic: 1, + name: 1, + lastMessage: 1, + ts: 1, + archived: 1, + usernames: 1, + usersCount: 1 + } + }).fetch(), total: RocketChat.models.Rooms.findByNameAndType(regex, 'c').count() }; }