From 37a8e7f2e2ad96a4aa4377f85b384a07ac879bb0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 30 Jun 2018 17:07:28 +0100 Subject: [PATCH] add setting to throw new RoomSubList hide behaviour behind an opt-in Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 1 + src/components/views/rooms/RoomList.js | 26 +++++++++++++++++------ src/settings/Settings.js | 5 +++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 6397e73434..d02d8b23e5 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -81,6 +81,7 @@ const SIMPLE_SETTINGS = [ { id: "VideoView.flipVideoHorizontally" }, { id: "TagPanel.disableTagPanel" }, { id: "enableWidgetScreenshots" }, + { id: "RoomSubList.showEmpty" }, ]; // These settings must be defined in SettingsStore diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 62ae96f47f..8533e3f61a 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -16,6 +16,8 @@ limitations under the License. */ 'use strict'; +import SettingsStore from "../../../settings/SettingsStore"; + const React = require("react"); const ReactDOM = require("react-dom"); import PropTypes from 'prop-types'; @@ -608,6 +610,10 @@ module.exports = React.createClass({ const RoomSubList = sdk.getComponent('structures.RoomSubList'); const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper"); + // XXX: we can't detect device-level (localStorage) settings onChange as the SettingsStore does not notify + // so checking on every render is the sanest thing at this time. + const showEmpty = SettingsStore.getValue('RoomSubList.showEmpty'); + const self = this; return ( + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} /> + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} /> + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} /> { Object.keys(self.state.lists).map((tagName) => { if (!tagName.match(STANDARD_TAGS_REGEX)) { @@ -688,7 +699,8 @@ module.exports = React.createClass({ collapsed={self.props.collapsed} searchFilter={self.props.searchFilter} onHeaderClick={self.onSubListHeaderClick} - onShowMoreRooms={self.onShowMoreRooms} />; + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} />; } }) } @@ -702,7 +714,8 @@ module.exports = React.createClass({ collapsed={self.props.collapsed} searchFilter={self.props.searchFilter} onHeaderClick={self.onSubListHeaderClick} - onShowMoreRooms={self.onShowMoreRooms} /> + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} /> + onShowMoreRooms={self.onShowMoreRooms} + showEmpty={showEmpty} /> ); diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 84178e2673..022fabc739 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -284,4 +284,9 @@ export const SETTINGS = { supportedLevels: ['room-device'], default: false, }, + "RoomSubList.showEmpty": { + supportedLevels: LEVELS_ACCOUNT_SETTINGS, + displayName: _td('Show empty room list headings'), + default: true, + }, };