Network status listens to some global events

Listen for reconnectTimer to display reconnection info. Listen for
unauthorized to update network status immediately after a failed login,
rather than waiting for the normal 5s interval to time out.

// FREEBIE
This commit is contained in:
lilia 2017-04-12 14:11:51 -07:00
parent d3492960a6
commit df65585e71
2 changed files with 7 additions and 3 deletions

View file

@ -221,6 +221,7 @@
if (e.name === 'HTTPError' && (e.code == 401 || e.code == 403)) {
Whisper.Registration.remove();
Whisper.events.trigger('unauthorized');
extension.install();
return;
}
@ -231,9 +232,7 @@
console.log('retrying in 1 minute');
setTimeout(init, 60000);
if (owsDesktopApp.inboxView) {
owsDesktopApp.inboxView.networkStatusView.setSocketReconnectInterval(60000);
}
Whisper.events.trigger('reconnectTimer');
} else {
console.log('offline');
messageReceiver.close();

View file

@ -19,6 +19,8 @@
window.addEventListener('online', this.update.bind(this));
window.addEventListener('offline', this.update.bind(this));
Whisper.events.on('unauthorized', this.update, this);
Whisper.events.on('reconnectTimer', this.onReconnectTimer, this);
this.model = new Backbone.Model();
this.listenTo(this.model, 'change', this.onChange);
@ -26,6 +28,9 @@
events: {
'click .openInstaller': extension.install
},
onReconnectTimer: function() {
this.setSocketReconnectInterval(60000);
},
finishConnectingGracePeriod: function() {
this.withinConnectingGracePeriod = false;
},