summaryrefslogtreecommitdiffstats
path: root/webapp/routes/route_team.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-01-27 09:30:33 -0500
committerChristopher Speller <crspeller@gmail.com>2017-01-27 09:30:33 -0500
commit8d2e8525a445a80085282142375b0cc68916d552 (patch)
treec2627b71c568346bbcca7be4a555744e3c2c757c /webapp/routes/route_team.jsx
parentcfbace70ca4222e7abba92c5e3af7440539452c7 (diff)
parent0d8bb03b5773923cf52f4d8cb2711131caae105c (diff)
downloadchat-8d2e8525a445a80085282142375b0cc68916d552.tar.gz
chat-8d2e8525a445a80085282142375b0cc68916d552.tar.bz2
chat-8d2e8525a445a80085282142375b0cc68916d552.zip
Merge branch 'release-3.6'
Diffstat (limited to 'webapp/routes/route_team.jsx')
-rw-r--r--webapp/routes/route_team.jsx17
1 files changed, 17 insertions, 0 deletions
diff --git a/webapp/routes/route_team.jsx b/webapp/routes/route_team.jsx
index 4cc85c81b..fe68324c4 100644
--- a/webapp/routes/route_team.jsx
+++ b/webapp/routes/route_team.jsx
@@ -8,6 +8,7 @@ import {browserHistory} from 'react-router/es6';
import TeamStore from 'stores/team_store.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {loadStatusesForChannelAndSidebar} from 'actions/status_actions.jsx';
+import {reconnect} from 'actions/websocket_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
@@ -60,12 +61,28 @@ function doChannelChange(state, replace, callback) {
callback();
}
+let wakeUpInterval;
+let lastTime = (new Date()).getTime();
+const WAKEUP_CHECK_INTERVAL = 30000; // 30 seconds
+const WAKEUP_THRESHOLD = 60000; // 60 seconds
+
function preNeedsTeam(nextState, replace, callback) {
if (RouteUtils.checkIfMFARequired(nextState)) {
browserHistory.push('/mfa/setup');
return;
}
+ clearInterval(wakeUpInterval);
+
+ wakeUpInterval = setInterval(() => {
+ const currentTime = (new Date()).getTime();
+ if (currentTime > (lastTime + WAKEUP_THRESHOLD)) { // ignore small delays
+ console.log('computer woke up - fetching latest'); //eslint-disable-line no-console
+ reconnect(false);
+ }
+ lastTime = currentTime;
+ }, WAKEUP_CHECK_INTERVAL);
+
// First check to make sure you're in the current team
// for the current url.
const teamName = nextState.params.team;