Skip to content

Commit

Permalink
show the disconnected icon when not online #164
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiaszCudnik committed Feb 4, 2019
1 parent b25b5dc commit 4d0781b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/stores/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,21 @@ export default class WalletStore {
}
this.io = io.connect(this.config.api_url);
this.io.on('connect', this.setConnected.bind(this, LoadingState.LOADED));
this.io.on(
'connecting',
this.setConnected.bind(this, LoadingState.LOADING)
);
this.io.on(
'reconnecting',
this.setConnected.bind(this, LoadingState.LOADING)
);
this.io.on('connecting', () => {
if (navigator.onLine) {
this.setConnected(LoadingState.LOADING);
}
});
this.io.on('reconnecting', () => {
if (navigator.onLine) {
this.setConnected(LoadingState.LOADING);
}
});
this.io.on(
'disconnect',
this.setConnected.bind(this, LoadingState.NOT_LOADED)
);
this.io.on('error', this.setConnected.bind(this, LoadingState.NOT_LOADED));
// react to browser events
if (typeof window !== 'undefined') {
window.addEventListener('online', this.io.connect.bind(this.io));
Expand Down

0 comments on commit 4d0781b

Please sign in to comment.