diff options
Diffstat (limited to 'webapp/client/web_client.jsx')
-rw-r--r-- | webapp/client/web_client.jsx | 19 |
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. |