summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-08-13 13:01:21 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-08-13 13:01:21 -0400
commitca919538cc402ed90ce42ffc3ef98994bb1081f4 (patch)
tree4ebc16d9c3092fbcf25dba68153868f8d277b0e0 /web/react/utils
parentd35065d6fd8237468ee3aa63bfba3b2aa29bc4af (diff)
downloadchat-ca919538cc402ed90ce42ffc3ef98994bb1081f4.tar.gz
chat-ca919538cc402ed90ce42ffc3ef98994bb1081f4.tar.bz2
chat-ca919538cc402ed90ce42ffc3ef98994bb1081f4.zip
Added ConfigStore that is populated from the server
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx26
-rw-r--r--web/react/utils/client.jsx15
-rw-r--r--web/react/utils/constants.jsx2
3 files changed, 43 insertions, 0 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index f35b0f6cc..afb9a1d79 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -4,6 +4,7 @@
var client = require('./client.jsx');
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
+var ConfigStore = require('../stores/config_store.jsx');
var PostStore = require('../stores/post_store.jsx');
var UserStore = require('../stores/user_store.jsx');
var utils = require('./utils.jsx');
@@ -383,3 +384,28 @@ module.exports.getMyTeam = function() {
}
);
}
+
+function getConfig() {
+ if (isCallInProgress('getConfig')) {
+ return;
+ }
+
+ callTracker['getConfig'] = utils.getTimestamp();
+ client.getConfig(
+ function(data, textStatus, xhr) {
+ callTracker['getConfig'] = 0;
+
+ if (data && xhr.status !== 304) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_CONFIG,
+ settings: data
+ });
+ }
+ },
+ function(err) {
+ callTracker['getConfig'] = 0;
+ dispatchError(err, 'getConfig');
+ }
+ );
+}
+module.exports.getConfig = getConfig;
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 6ae25c66d..250e3edbd 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -850,6 +850,21 @@ module.exports.updateValetFeature = function(data, success, error) {
module.exports.track('api', 'api_teams_update_valet_feature');
};
+function getConfig(success, error) {
+ $.ajax({
+ url: '/api/v1/config/get_all',
+ dataType: 'json',
+ type: 'GET',
+ ifModified: true,
+ success: success,
+ error: function(xhr, status, err) {
+ var e = handleError('getConfig', xhr, status, err);
+ error(e);
+ }
+ });
+};
+module.exports.getConfig = getConfig;
+
module.exports.isEmailEnabledSynchronous = function() {
var enabled = false;
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index bed0ec556..36c6ab653 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -30,6 +30,8 @@ module.exports = {
CLICK_TEAM: null,
RECIEVED_TEAM: null,
+
+ RECIEVED_CONFIG: null
}),
PayloadSources: keyMirror({