From 3815ab806585afa205c074c0b40ddc31e4314190 Mon Sep 17 00:00:00 2001 From: nickago Date: Thu, 6 Aug 2015 11:05:13 -0700 Subject: Added keys to array-based elements and made getMe asynchronous --- web/react/components/post_list.jsx | 14 +++++++------- web/react/components/settings_sidebar.jsx | 3 ++- web/react/components/sidebar_header.jsx | 3 ++- web/react/stores/user_store.jsx | 14 +------------- web/react/utils/async_client.jsx | 2 +- web/react/utils/client.jsx | 14 +++----------- 6 files changed, 16 insertions(+), 34 deletions(-) diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index bb1b1704c..0ee7e9969 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -439,9 +439,9 @@ module.exports = React.createClass({ currentPostDay = utils.getDateForUnixTicks(post.create_at); if (currentPostDay.toDateString() != previousPostDay.toDateString()) { postCtls.push( -
-
-
{currentPostDay.toDateString()}
+
+
+
{currentPostDay.toDateString()}
); } @@ -449,9 +449,9 @@ module.exports = React.createClass({ if (post.create_at > last_viewed && !rendered_last_viewed) { rendered_last_viewed = true; postCtls.push( -
-
-
New Messages
+
+
+
New Messages
); } @@ -459,7 +459,7 @@ module.exports = React.createClass({ previousPostDay = currentPostDay; } } else { - postCtls.push(); + postCtls.push(); } return ( diff --git a/web/react/components/settings_sidebar.jsx b/web/react/components/settings_sidebar.jsx index ae8510cf2..b4d291622 100644 --- a/web/react/components/settings_sidebar.jsx +++ b/web/react/components/settings_sidebar.jsx @@ -4,6 +4,7 @@ var utils = require('../utils/utils.jsx'); module.exports = React.createClass({ + displayName:'SettingsSidebar', updateTab: function(tab) { this.props.updateTab(tab); $('.settings-modal').addClass('display--content'); @@ -14,7 +15,7 @@ module.exports = React.createClass({
diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx index ba8f9bacd..023de3a19 100644 --- a/web/react/components/sidebar_header.jsx +++ b/web/react/components/sidebar_header.jsx @@ -87,7 +87,8 @@ var NavbarDropdown = React.createClass({ } }); } - teams.push(
  • Create a New Team
  • ); + teams.push(
  • Create a New Team
  • ); + return (
      diff --git a/web/react/stores/user_store.jsx b/web/react/stores/user_store.jsx index aff5a0bed..85cb4c9ee 100644 --- a/web/react/stores/user_store.jsx +++ b/web/react/stores/user_store.jsx @@ -4,7 +4,6 @@ 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; @@ -73,24 +72,13 @@ var UserStore = assign({}, EventEmitter.prototype, { BrowserStore.setGlobalItem("current_user_id", id); } }, - getCurrentId: function(skipFetch) { + getCurrentId: function() { var current_id = this._current_id; if (current_id == null) { current_id = BrowserStore.getGlobalItem("current_user_id"); } - // this is a speical case to force fetch the - // current user if it's missing - // it's synchronous to block rendering - if (current_id == null && !skipFetch) { - var me = client.getMeSynchronous(); - if (me != null) { - this.setCurrentUser(me); - current_id = me.id; - } - } - return current_id; }, getCurrentUser: function(skipFetch) { diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index dc4fc1096..f35b0f6cc 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -322,7 +322,7 @@ module.exports.getMe = function() { if (isCallInProgress("getMe")) return; callTracker["getMe"] = utils.getTimestamp(); - client.getMeSynchronous( + client.getMe( function(data, textStatus, xhr) { callTracker["getMe"] = 0; diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index b8eda0075..3375da7cf 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -279,32 +279,24 @@ module.exports.getAudits = function(userId, success, error) { }); }; -module.exports.getMeSynchronous = function(success, error) { - - var current_user = null; +module.exports.getMe = function(success, error) { $.ajax({ - async: false, url: "/api/v1/users/me", dataType: 'json', contentType: 'application/json', type: 'GET', - success: function(data, textStatus, xhr) { - current_user = data; - if (success) success(data, textStatus, xhr); - }, + success: success, error: function(xhr, status, err) { var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) { if (error) { - e = handleError("getMeSynchronous", xhr, status, err); + e = handleError("getMe", xhr, status, err); error(e); }; }; } }); - - return current_user; }; module.exports.inviteMembers = function(data, success, error) { -- cgit v1.2.3-1-g7c22