From ff741740eebceb43b1d69b13d97ae7eed2aa32d1 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Mon, 13 Feb 2017 09:27:28 -0500
Subject: Increase performance when receiving messages (#5375)

---
 webapp/components/needs_team.jsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'webapp/components/needs_team.jsx')

diff --git a/webapp/components/needs_team.jsx b/webapp/components/needs_team.jsx
index 0b91814c3..fb6029c2b 100644
--- a/webapp/components/needs_team.jsx
+++ b/webapp/components/needs_team.jsx
@@ -42,6 +42,8 @@ import SelectTeamModal from 'components/admin_console/select_team_modal.jsx';
 import iNoBounce from 'inobounce';
 import * as UserAgent from 'utils/user_agent.jsx';
 
+const UNREAD_CHECK_TIME_MILLISECONDS = 10000;
+
 export default class NeedsTeam extends React.Component {
     constructor(params) {
         super(params);
@@ -49,6 +51,8 @@ export default class NeedsTeam extends React.Component {
         this.onTeamChanged = this.onTeamChanged.bind(this);
         this.onPreferencesChanged = this.onPreferencesChanged.bind(this);
 
+        this.blurTime = new Date().getTime();
+
         const team = TeamStore.getCurrent();
 
         this.state = {
@@ -97,11 +101,16 @@ export default class NeedsTeam extends React.Component {
             AsyncClient.viewChannel();
             ChannelStore.resetCounts(ChannelStore.getCurrentId());
             ChannelStore.emitChange();
+
             window.isActive = true;
+            if (new Date().getTime() - this.blurTime > UNREAD_CHECK_TIME_MILLISECONDS) {
+                AsyncClient.getMyChannelMembers();
+            }
         });
 
         $(window).on('blur', () => {
             window.isActive = false;
+            this.blurTime = new Date().getTime();
             if (UserStore.getCurrentUser()) {
                 AsyncClient.viewChannel('');
             }
-- 
cgit v1.2.3-1-g7c22

