summaryrefslogtreecommitdiffstats
path: root/webapp/client/web_client.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-11-29 10:37:59 -0500
committerenahum <nahumhbl@gmail.com>2016-11-29 12:37:59 -0300
commit557aa68636ae8b23b33b761d9e9fe0f5b8cf1120 (patch)
tree72bdbdb053bc7a281bcf15c8d5dfc0ab185d1944 /webapp/client/web_client.jsx
parent58215e573fec44fe9cadf09909b44007ef5c18e6 (diff)
downloadchat-557aa68636ae8b23b33b761d9e9fe0f5b8cf1120.tar.gz
chat-557aa68636ae8b23b33b761d9e9fe0f5b8cf1120.tar.bz2
chat-557aa68636ae8b23b33b761d9e9fe0f5b8cf1120.zip
PLT-4233 When internet reconnects, reconnect websocket and grab latest posts, etc. (#4500)
* When internet reconnects, reconnect websocket and grab latest posts, etc. * Rename internet connection variable
Diffstat (limited to 'webapp/client/web_client.jsx')
-rw-r--r--webapp/client/web_client.jsx19
1 files changed, 17 insertions, 2 deletions
diff --git a/webapp/client/web_client.jsx b/webapp/client/web_client.jsx
index 85ced325e..62870c5bc 100644
--- a/webapp/client/web_client.jsx
+++ b/webapp/client/web_client.jsx
@@ -2,9 +2,12 @@
// See License.txt for license information.
import Client from './client.jsx';
-import TeamStore from '../stores/team_store.jsx';
-import BrowserStore from '../stores/browser_store.jsx';
+
+import TeamStore from 'stores/team_store.jsx';
+import BrowserStore from 'stores/browser_store.jsx';
+
import * as GlobalActions from 'actions/global_actions.jsx';
+import {reconnect} from 'actions/websocket_actions.jsx';
import request from 'superagent';
@@ -14,6 +17,7 @@ class WebClientClass extends Client {
constructor() {
super();
this.enableLogErrorsToConsole(true);
+ this.hasInternetConnection = true;
TeamStore.addChangeListener(this.onTeamStoreChanged.bind(this));
}
@@ -37,6 +41,17 @@ class WebClientClass extends Client {
if (err.status === HTTP_UNAUTHORIZED && res.req.url !== '/api/v3/users/login') {
GlobalActions.emitUserLoggedOutEvent('/login');
}
+
+ if (err.status == null) {
+ this.hasInternetConnection = false;
+ }
+ }
+
+ handleSuccess = (res) => { // eslint-disable-line no-unused-vars
+ if (res && !this.hasInternetConnection) {
+ reconnect();
+ this.hasInternetConnection = true;
+ }
}
// not sure why but super.login doesn't work if using an () => arrow functions.