From a2f7de52c3d18232e18ebb65730069071ea31955 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Tue, 27 Jun 2017 23:49:03 -0400
Subject: Remove unnecessary API calls on first page load (#6762)

---
 webapp/routes/route_team.jsx | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

(limited to 'webapp/routes/route_team.jsx')

diff --git a/webapp/routes/route_team.jsx b/webapp/routes/route_team.jsx
index d048cb5c9..f8ff3b593 100644
--- a/webapp/routes/route_team.jsx
+++ b/webapp/routes/route_team.jsx
@@ -103,18 +103,17 @@ function preNeedsTeam(nextState, replace, callback) {
         return;
     }
 
+    // If current team is set, then this is not first load
+    // The first load action pulls team unreads
+    if (TeamStore.getCurrentId()) {
+        getMyTeamUnreads()(dispatch, getState);
+    }
+
     TeamStore.saveMyTeam(team);
     BrowserStore.setGlobalItem('team', team.id);
     TeamStore.emitChange();
     GlobalActions.emitCloseRightHandSide();
 
-    if (nextState.location.pathname.indexOf('/channels/') > -1 ||
-        nextState.location.pathname.indexOf('/pl/') > -1 ||
-        nextState.location.pathname.indexOf('/messages/') > -1) {
-        getMyTeamUnreads()(dispatch, getState);
-        fetchMyChannelsAndMembers(team.id)(dispatch, getState);
-    }
-
     const d1 = $.Deferred(); //eslint-disable-line new-cap
 
     fetchMyChannelsAndMembers(team.id)(dispatch, getState).then(
-- 
cgit v1.2.3-1-g7c22

