From cbeee72062c6e9f4fb7fb3e24b91beb92454d1f6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Feb 2018 10:11:04 -0700 Subject: [PATCH] Don't show empty custom tags when filtering tags Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomList.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 41a200420d..68b171b0ee 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -34,6 +34,7 @@ import RoomListStore from '../../../stores/RoomListStore'; import GroupStoreCache from '../../../stores/GroupStoreCache'; const HIDE_CONFERENCE_CHANS = true; +const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority)|im\.vector\.fake\.(invite|recent|direct|archived))$/; function phraseForSection(section) { switch (section) { @@ -365,7 +366,7 @@ module.exports = React.createClass({ }); Object.keys(lists).forEach((tagName) => { - filteredLists[tagName] = lists[tagName].filter((taggedRoom) => { + const filteredRooms = lists[tagName].filter((taggedRoom) => { // Somewhat impossible, but guard against it anyway if (!taggedRoom) { return; @@ -377,6 +378,10 @@ module.exports = React.createClass({ return Boolean(isRoomVisible[taggedRoom.roomId]); }); + + if (filteredRooms.length > 0 || tagName.match(STANDARD_TAGS_REGEX)) { + filteredLists[tagName] = filteredRooms; + } }); return filteredLists; @@ -682,7 +687,7 @@ module.exports = React.createClass({ onShowMoreRooms={self.onShowMoreRooms} /> { Object.keys(self.state.lists).map((tagName) => { - if (!tagName.match(/^(m\.(favourite|lowpriority)|im\.vector\.fake\.(invite|recent|direct|archived))$/)) { + if (!tagName.match(STANDARD_TAGS_REGEX)) { return