From 82624c10a5066bc529e348e011117031a101bdfe Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 8 Jan 2021 11:19:32 +0100 Subject: [PATCH] Open 'cache' apps when the worker is stuck offline --- www/common/outer/async-store.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 9a1d25cc2..5d26534fb 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -2531,6 +2531,7 @@ define([ var onCacheReady = function (clientId, cb) { var proxy = store.proxy; + if (store.manager) { return void cb(); } if (!proxy.settings) { proxy.settings = NEW_USER_SETTINGS; } if (!proxy.friends_pending) { proxy.friends_pending = {}; } var unpin = function (data, cb) { @@ -2757,10 +2758,11 @@ define([ returned.anonHash = Hash.getEditHashFromKeys(secret); } }).on('cacheready', function (info) { - if (!data.cache) { return; } store.offline = true; store.realtime = info.realtime; store.networkPromise = info.networkPromise; + store.cacheReturned = returned; + if (!data.cache) { return; } // Make sure we have a valid user object before emitting cacheready if (rt.proxy && !rt.proxy.drive) { return; } @@ -2857,6 +2859,14 @@ define([ Store.init = function (clientId, data, _callback) { var callback = Util.once(_callback); + if (!store.returned && data.cache && store.cacheReturned) { + return void onCacheReady(clientId, function () { + callback({ + state: 'ALREADY_INIT', + returned: store.cacheReturned + }); + }); + } if (initialized) { return void whenReady(function () { callback({