diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-08-14 08:48:24 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-08-14 08:48:24 -0400 |
commit | 92c4df5b109ac8b15f6384a5c027024696bbd4d8 (patch) | |
tree | 41a18a9bcbbcc7cd961cc424878ac37aade5c288 /web/react/stores/config_store.jsx | |
parent | a8930cbabec21635a10e8cac4d2c0c79867f283d (diff) | |
parent | 8fc4456213c5ee16863b7f1bcb20e35a19469a1d (diff) | |
download | chat-92c4df5b109ac8b15f6384a5c027024696bbd4d8.tar.gz chat-92c4df5b109ac8b15f6384a5c027024696bbd4d8.tar.bz2 chat-92c4df5b109ac8b15f6384a5c027024696bbd4d8.zip |
Merge pull request #370 from hmhealey/mm1812
MM-1812 Provide warnings on team invite screens when email is disabled
Diffstat (limited to 'web/react/stores/config_store.jsx')
-rw-r--r-- | web/react/stores/config_store.jsx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/web/react/stores/config_store.jsx b/web/react/stores/config_store.jsx new file mode 100644 index 000000000..7ff177b35 --- /dev/null +++ b/web/react/stores/config_store.jsx @@ -0,0 +1,56 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var AppDispatcher = require('../dispatcher/app_dispatcher.jsx'); +var EventEmitter = require('events').EventEmitter; +var assign = require('object-assign'); + +var BrowserStore = require('../stores/browser_store.jsx'); + +var Constants = require('../utils/constants.jsx'); +var ActionTypes = Constants.ActionTypes; + +var CHANGE_EVENT = 'change'; + +var ConfigStore = assign({}, EventEmitter.prototype, { + emitChange: function emitChange() { + this.emit(CHANGE_EVENT); + }, + addChangeListener: function addChangeListener(callback) { + this.on(CHANGE_EVENT, callback); + }, + removeChangeListener: function removeChangeListener(callback) { + this.removeListener(CHANGE_EVENT, callback); + }, + getSetting: function getSetting(key, defaultValue) { + return BrowserStore.getItem('config_' + key, defaultValue); + }, + getSettingAsBoolean: function getSettingAsNumber(key, defaultValue) { + var value = ConfigStore.getSetting(key, defaultValue); + + if (typeof value !== 'string') { + return !!value; + } else { + return value === 'true'; + } + }, + updateStoredSettings: function updateStoredSettings(settings) { + for (var key in settings) { + BrowserStore.setItem('config_' + key, settings[key]); + } + } +}); + +ConfigStore.dispatchToken = AppDispatcher.register(function registry(payload) { + var action = payload.action; + + switch (action.type) { + case ActionTypes.RECIEVED_CONFIG: + ConfigStore.updateStoredSettings(action.settings); + ConfigStore.emitChange(); + break; + default: + } +}); + +module.exports = ConfigStore; |