From 3a0172f5f9687200ad261bf62f11defaa875d5e7 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 14 Dec 2019 17:26:01 +0000 Subject: re-connect after idle timeout properly. Another horror caused by some unexpected vex change, now we listen for afterClose to be sure that when the dialog is gone we started to try to re-connect. Change-Id: Ic053df665d188f25f6ddf3b081433bbd6dd37820 --- loleaflet/src/core/Socket.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 706234980..653b71366 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -453,18 +453,30 @@ L.Socket = L.Class.extend({ message = msg; } - var dialogOpened = vex.dialog.open({ + var dialogOptions = { message: message, contentClassName: 'loleaflet-user-idle' - }); + }; + var restartConnectionFn; if (textMsg === 'idle' || textMsg === 'oom') { var map = this._map; - dialogOpened.contentEl.onclick = function() { - console.debug('idleness: reactivating'); - map._documentIdle = false; - return map._activate(); + restartConnectionFn = function() { + if (map._documentIdle) + { + console.debug('idleness: reactivating'); + map._documentIdle = false; + return map._activate(); + } + return false; }; + dialogOptions.afterClose = restartConnectionFn; + } + + var dialogOpened = vex.dialog.open(dialogOptions); + + if (textMsg === 'idle' || textMsg === 'oom') { + dialogOpened.contentEl.onclick = restartConnectionFn; $('.vex-overlay').addClass('loleaflet-user-idle-overlay'); } -- cgit v1.2.3