From 31d7e652fe9f392df9015e82e366303a57fe1ecb Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 26 Jul 2017 11:32:02 -0700 Subject: [PATCH] Dismiss the app loading screen if we failed to connect to socket FREEBIE --- js/views/inbox_view.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index ed745b14b3..387b36c7ce 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -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) {