Don't show empty custom tags when filtering tags

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/21833/head
Travis Ralston 2018-02-16 10:11:04 -07:00 committed by GitHub
parent ad863afd6d
commit cbeee72062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -34,6 +34,7 @@ import RoomListStore from '../../../stores/RoomListStore';
import GroupStoreCache from '../../../stores/GroupStoreCache'; import GroupStoreCache from '../../../stores/GroupStoreCache';
const HIDE_CONFERENCE_CHANS = true; const HIDE_CONFERENCE_CHANS = true;
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority)|im\.vector\.fake\.(invite|recent|direct|archived))$/;
function phraseForSection(section) { function phraseForSection(section) {
switch (section) { switch (section) {
@ -365,7 +366,7 @@ module.exports = React.createClass({
}); });
Object.keys(lists).forEach((tagName) => { Object.keys(lists).forEach((tagName) => {
filteredLists[tagName] = lists[tagName].filter((taggedRoom) => { const filteredRooms = lists[tagName].filter((taggedRoom) => {
// Somewhat impossible, but guard against it anyway // Somewhat impossible, but guard against it anyway
if (!taggedRoom) { if (!taggedRoom) {
return; return;
@ -377,6 +378,10 @@ module.exports = React.createClass({
return Boolean(isRoomVisible[taggedRoom.roomId]); return Boolean(isRoomVisible[taggedRoom.roomId]);
}); });
if (filteredRooms.length > 0 || tagName.match(STANDARD_TAGS_REGEX)) {
filteredLists[tagName] = filteredRooms;
}
}); });
return filteredLists; return filteredLists;
@ -682,7 +687,7 @@ module.exports = React.createClass({
onShowMoreRooms={self.onShowMoreRooms} /> onShowMoreRooms={self.onShowMoreRooms} />
{ Object.keys(self.state.lists).map((tagName) => { { 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 <RoomSubList list={self.state.lists[tagName]} return <RoomSubList list={self.state.lists[tagName]}
key={tagName} key={tagName}
label={tagName} label={tagName}