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 = new Whisper.AppLoadingScreen();
|
||||||
this.appLoadingScreen.render();
|
this.appLoadingScreen.render();
|
||||||
this.appLoadingScreen.$el.prependTo(this.el);
|
this.appLoadingScreen.$el.prependTo(this.el);
|
||||||
|
this.startConnectionListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
var inboxCollection = getInboxCollection();
|
var inboxCollection = getInboxCollection();
|
||||||
|
@ -170,6 +171,27 @@
|
||||||
'click .restart-signal': 'reloadBackgroundPage',
|
'click .restart-signal': 'reloadBackgroundPage',
|
||||||
'show .lightbox': 'showLightbox'
|
'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() {
|
onEmpty: function() {
|
||||||
var view = this.appLoadingScreen;
|
var view = this.appLoadingScreen;
|
||||||
if (view) {
|
if (view) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue