summaryrefslogtreecommitdiffstats
path: root/web/react/stores
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/stores')
-rw-r--r--web/react/stores/user_store.jsx14
1 files changed, 13 insertions, 1 deletions
diff --git a/web/react/stores/user_store.jsx b/web/react/stores/user_store.jsx
index f8616c6ab..248495dac 100644
--- a/web/react/stores/user_store.jsx
+++ b/web/react/stores/user_store.jsx
@@ -4,6 +4,7 @@
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');
+var client = require('../utils/client.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
@@ -72,7 +73,7 @@ var UserStore = assign({}, EventEmitter.prototype, {
BrowserStore.setGlobalItem('current_user_id', id);
}
},
- getCurrentId: function() {
+ getCurrentId: function(skipFetch) {
var currentId = this.gCurrentId;
if (currentId == null) {
@@ -80,6 +81,17 @@ var UserStore = assign({}, EventEmitter.prototype, {
this.gCurrentId = currentId;
}
+ // this is a special case to force fetch the
+ // current user if it's missing
+ // it's synchronous to block rendering
+ if (currentId == null && !skipFetch) {
+ var me = client.getMeSynchronous();
+ if (me != null) {
+ this.setCurrentUser(me);
+ currentId = me.id;
+ }
+ }
+
return currentId;
},
getCurrentUser: function() {