Dismiss the app loading screen if we failed to connect to socket

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-07-26 11:32:02 -07:00
parent af2ce56c8d
commit 31d7e652fe

View file

@ -102,6 +102,7 @@
this.appLoadingScreen = new Whisper.AppLoadingScreen();
this.appLoadingScreen.render();
this.appLoadingScreen.$el.prependTo(this.el);
this.startConnectionListener();
}
var inboxCollection = getInboxCollection();
@ -170,6 +171,27 @@
'click .restart-signal': 'reloadBackgroundPage',
'show .lightbox': 'showLightbox'
},
startConnectionListener: function() {
this.interval = setInterval(function() {
var status = window.getSocketStatus();
switch(status) {
case WebSocket.CONNECTING:
break;
case WebSocket.OPEN:
clearInterval(this.interval);
// if we've connected, we can wait for real empty event
this.interval = null;
break;
case WebSocket.CLOSING:
case WebSocket.CLOSED:
clearInterval(this.interval);
this.interval = null;
// if we failed to connect, we pretend we got an empty event
this.onEmpty();
break;
}
}.bind(this), 1000);
},
onEmpty: function() {
var view = this.appLoadingScreen;
if (view) {