From 290763d6c5ef305c8243b5454bc5932d82f76ea6 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 17 Aug 2017 15:07:34 +0200 Subject: [PATCH] don't complain about bad realtime state just because you disconnected --- www/common/common-realtime.js | 8 ++++++++ www/common/cryptpad-common.js | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/www/common/common-realtime.js b/www/common/common-realtime.js index d592ae70e..5b0483008 100644 --- a/www/common/common-realtime.js +++ b/www/common/common-realtime.js @@ -8,6 +8,8 @@ define([ var BAD_STATE_TIMEOUT = typeof(AppConfig.badStateTimeout) === 'number'? AppConfig.badStateTimeout: 30000; + var connected = false; + /* TODO make this not blow up when disconnected or lagging... */ @@ -20,6 +22,7 @@ define([ } var to = setTimeout(function () { + if (!connected) { return; } realtime.abort(); // don't launch more than one popup if (common.infiniteSpinnerDetected) { return; } @@ -38,5 +41,10 @@ define([ }, 0); }; + common.setConnectionState = function (bool) { + if (typeof(bool) !== 'boolean') { return; } + connected = bool; + }; + return common; }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 36dd6eeed..88ad0fde7 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1849,12 +1849,18 @@ define([ Store.ready(function (err, storeObj) { store = common.store = env.store = storeObj; - common.addDirectMessageHandler(common); var proxy = getProxy(); var network = getNetwork(); + network.on('disconnect', function () { + Realtime.setConnectionState(false); + }); + network.on('reconnect', function () { + Realtime.setConnectionState(true); + }); + if (Object.keys(proxy).length === 1) { feedback("FIRST_APP_USE", true); }