guard custom tags with feature flag

This commit is contained in:
Bruno Windels 2019-02-07 18:04:30 +00:00
parent b50bfa1eda
commit e8533beafb
6 changed files with 29 additions and 7 deletions

View file

@ -18,6 +18,7 @@ import * as RoomNotifs from '../RoomNotifs';
import RoomListStore from './RoomListStore';
import EventEmitter from 'events';
import { throttle } from "lodash";
import SettingsStore from "../settings/SettingsStore";
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;
@ -50,6 +51,7 @@ class CustomRoomTagStore extends EventEmitter {
super();
// Initialise state
this._state = {tags: {}};
// as RoomListStore gets updated by every timeline event
// throttle this to only run every 500ms
this._getUpdatedTags = throttle(
@ -133,6 +135,10 @@ class CustomRoomTagStore extends EventEmitter {
}
_getUpdatedTags() {
if (!SettingsStore.isFeatureEnabled("feature_custom_tags")) {
return;
}
const newTagNames = Object.keys(RoomListStore.getRoomLists())
.filter((tagName) => {
return !tagName.match(STANDARD_TAGS_REGEX);

View file

@ -202,6 +202,8 @@ class RoomListStore extends Store {
// If somehow we dispatched a RoomListActions.tagRoom.failure before a MatrixActions.sync
if (!this._matrixClient) return;
const isCustomTagsEnabled = SettingsStore.isFeatureEnabled("feature_custom_tags");
this._matrixClient.getRooms().forEach((room, index) => {
const myUserId = this._matrixClient.getUserId();
const membership = room.getMyMembership();
@ -226,7 +228,7 @@ class RoomListStore extends Store {
// ignore any m. tag names we don't know about
tagNames = tagNames.filter((t) => {
return !t.startsWith('m.') || lists[t] !== undefined;
return (isCustomTagsEnabled && !t.startsWith('m.')) || lists[t] !== undefined;
});
if (tagNames.length) {