Dismiss the app loading screen if we failed to connect to socket
FREEBIE
This commit is contained in:
parent
af2ce56c8d
commit
31d7e652fe
1 changed files with 22 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue