From cf5a0b05c09ad7b23265a96a944c82de71dfa3fc Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 29 Dec 2019 01:07:10 +0100 Subject: Fixed UI not working on pages were sessionStorage is disabled. --- src/lib/SyncMessage.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index c889b2c..698822c 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -253,10 +253,16 @@ let r = new XMLHttpRequest(); let result; let key = `${ENDPOINT_PREFIX}`; - let reloaded = sessionStorage.getItem(key) === "reloaded"; - if (reloaded) { - sessionStorage.removeItem(key); - console.log("Syncmessage attempt aftert reloading page."); + let reloaded; + try { + reloaded = sessionStorage.getItem(key) === "reloaded"; + if (reloaded) { + sessionStorage.removeItem(key); + console.log("Syncmessage attempt aftert reloading page."); + } + } catch (e) { + // we can't access sessionStorage: let's act as we've already reloaded + reloaded = true; } for (let attempts = 3; attempts-- > 0;) { try { @@ -268,7 +274,7 @@ console.error(`syncMessage error in ${document.URL}: ${e.message} (response ${r.responseText}, remaining attempts ${attempts})`); if (attempts === 0) { if (reloaded) { - console.log("Already reloaded, giving up.") + console.log("Already reloaded or no sessionStorage, giving up.") break; } sessionStorage.setItem(key, "reloaded"); -- cgit v1.2.3