Remove SdkConfig

just take a config in MatrixChat, pass the individual things down through the chain.

This may become unwieldy: let's see how it goes.
pull/21833/head
David Baker 2016-06-08 14:54:34 +01:00
parent 12816c5e1f
commit 7e8c8dd336
3 changed files with 5 additions and 53 deletions

View File

@ -1,48 +0,0 @@
/*
Copyright 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var DEFAULTS = {
};
/**
* Class that stores an instance of the SDK config dictionary
* as a singleton such that it can be accessed from SDK
* components without having to be passed deep though
* multiple levels of React components.
*/
class SdkConfig {
static get() {
return global.mxReactSdkConfig;
}
static put(cfg) {
var defaultKeys = Object.keys(DEFAULTS);
for (var i = 0; i < defaultKeys.length; ++i) {
var key = defaultKeys[i];
if (cfg[key] === undefined) {
cfg[key] = DEFAULTS[key];
}
}
global.mxReactSdkConfig = cfg;
}
static unset() {
global.mxReactSdkConfig = undefined;
}
}
module.exports = SdkConfig;

View File

@ -19,7 +19,6 @@ var url = require('url');
var Favico = require('favico.js'); var Favico = require('favico.js');
var MatrixClientPeg = require("../../MatrixClientPeg"); var MatrixClientPeg = require("../../MatrixClientPeg");
var SdkConfig = require("../../SdkConfig");
var Notifier = require("../../Notifier"); var Notifier = require("../../Notifier");
var ContextualMenu = require("../../ContextualMenu"); var ContextualMenu = require("../../ContextualMenu");
var RoomListSorter = require("../../RoomListSorter"); var RoomListSorter = require("../../RoomListSorter");
@ -124,7 +123,6 @@ module.exports = React.createClass({
}, },
componentWillMount: function() { componentWillMount: function() {
SdkConfig.put(this.props.config);
this.favicon = new Favico({animation: 'none'}); this.favicon = new Favico({animation: 'none'});
}, },
@ -1094,7 +1092,7 @@ module.exports = React.createClass({
right_panel = <RightPanel roomId={this.state.currentRoom} collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity} /> right_panel = <RightPanel roomId={this.state.currentRoom} collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity} />
break; break;
case this.PageTypes.UserSettings: case this.PageTypes.UserSettings:
page_element = <UserSettings onClose={this.onUserSettingsClose} version={this.state.version} /> page_element = <UserSettings onClose={this.onUserSettingsClose} version={this.state.version} brand={this.props.config.brand} />
right_panel = <RightPanel collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity}/> right_panel = <RightPanel collapsed={this.state.collapse_rhs} opacity={this.state.sideOpacity}/>
break; break;
case this.PageTypes.CreateRoom: case this.PageTypes.CreateRoom:

View File

@ -31,7 +31,9 @@ module.exports = React.createClass({
propTypes: { propTypes: {
version: React.PropTypes.string, version: React.PropTypes.string,
onClose: React.PropTypes.func onClose: React.PropTypes.func,
// The brand string given when creating email pushers
brand: React.PropTypes.string,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -333,7 +335,7 @@ module.exports = React.createClass({
<h3>Notifications</h3> <h3>Notifications</h3>
<div className="mx_UserSettings_section"> <div className="mx_UserSettings_section">
<Notifications threepids={this.state.threepids} /> <Notifications threepids={this.state.threepids} brand={this.props.brand} />
</div> </div>
</div>); </div>);
} }