From fb5b57836ece6da2d0136802ca0d08346638b9e2 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Tue, 3 Nov 2015 14:52:25 -0500
Subject: Multiple fixes to major performance issues with teams with 50+ users

---
 web/react/utils/async_client.jsx | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'web/react/utils/async_client.jsx')

diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 75dd35e3f..0ecd26186 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -588,13 +588,21 @@ export function getMe() {
 }
 
 export function getStatuses() {
-    if (isCallInProgress('getStatuses')) {
+    const directChannels = ChannelStore.getAll().filter((channel) => channel.type === Constants.DM_CHANNEL);
+
+    const teammateIds = [];
+    for (var i = 0; i < directChannels.length; i++) {
+        const teammate = utils.getDirectTeammate(directChannels[i].id);
+        teammateIds.push(teammate.id);
+    }
+
+    if (isCallInProgress('getStatuses') || teammateIds.length === 0) {
         return;
     }
 
     callTracker.getStatuses = utils.getTimestamp();
-    client.getStatuses(
-        function getStatusesSuccess(data, textStatus, xhr) {
+    client.getStatuses(teammateIds,
+        (data, textStatus, xhr) => {
             callTracker.getStatuses = 0;
 
             if (xhr.status === 304 || !data) {
@@ -606,7 +614,7 @@ export function getStatuses() {
                 statuses: data
             });
         },
-        function getStatusesFailure(err) {
+        (err) => {
             callTracker.getStatuses = 0;
             dispatchError(err, 'getStatuses');
         }
-- 
cgit v1.2.3-1-g7c22


From a26145ef91197ba374d525c947984ae672cbd94d Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Tue, 3 Nov 2015 15:11:16 -0500
Subject: Minor changes to statuses client code

---
 web/react/utils/async_client.jsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'web/react/utils/async_client.jsx')

diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 0ecd26186..205c7461c 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -593,7 +593,9 @@ export function getStatuses() {
     const teammateIds = [];
     for (var i = 0; i < directChannels.length; i++) {
         const teammate = utils.getDirectTeammate(directChannels[i].id);
-        teammateIds.push(teammate.id);
+        if (teammate) {
+            teammateIds.push(teammate.id);
+        }
     }
 
     if (isCallInProgress('getStatuses') || teammateIds.length === 0) {
-- 
cgit v1.2.3-1-g7c22

