From fb1fd88947d0689b6500bc65ba57d29911d290e5 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Mon, 11 Jan 2016 12:19:31 -0600 Subject: [PATCH] Tweaks to disconnection/reconnection UI --- srcjs/shinyapp.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/srcjs/shinyapp.js b/srcjs/shinyapp.js index 95b9bf742..95c0d605a 100644 --- a/srcjs/shinyapp.js +++ b/srcjs/shinyapp.js @@ -96,7 +96,7 @@ var ShinyApp = function() { socket: socket }); - exports.onSocketConnected(); + exports.hideReconnectDialog(); socket.send(JSON.stringify({ method: 'init', @@ -123,7 +123,6 @@ var ShinyApp = function() { }); self.$notifyDisconnected(); - exports.onSocketDisconnected(); } self.$removeSocket(); @@ -131,7 +130,10 @@ var ShinyApp = function() { // To try a reconnect, both the app (self.$allowReconnect) and the // server (socket.allowReconnect) must allow reconnections. if (self.$allowReconnect === true && socket.allowReconnect === true) { + exports.showReconnectDialog(); self.$scheduleReconnect(); + } else { + $(document.body).addClass('disconnected'); } }; return socket; @@ -187,7 +189,11 @@ var ShinyApp = function() { setTimeout(function() { self.reconnect(); }, 1000); }; - exports.onSocketDisconnected = function() { + exports.showReconnectDialog = function() { + // If there's already a reconnect dialog, don't add another + if ($('.shiny-reconnect-dialog-wrapper').length > 0) + return; + var $dialog = $('
' + '
' + '' + @@ -222,7 +228,7 @@ var ShinyApp = function() { updateDots(); }; - exports.onSocketConnected = function() { + exports.hideReconnectDialog = function() { $(".shiny-reconnect-dialog-wrapper").remove(); };