From e9d65e6495f312948806e79a0c3e84bc37883d0a Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 5 Sep 2023 19:01:53 +0100 Subject: [PATCH] Load promises on startup, correct promise store key --- js/main.js | 1 + js/promise.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 6cd76a2..f40dcfd 100644 --- a/js/main.js +++ b/js/main.js @@ -84,6 +84,7 @@ function checkPersist() { g_persist.forEach((v) => { v.put('foo'); }); + scanPromises(); } diff --git a/js/promise.js b/js/promise.js index 97e70b8..436a820 100644 --- a/js/promise.js +++ b/js/promise.js @@ -5,7 +5,7 @@ async function putPromise(o) { h.update(v); const z = h.getHash("HEX"); g_persistIndex.push(z); - localStorage.setItem('persist', JSON.stringify(g_persistIndex)); + localStorage.setItem(PERSIST_STORAGEKEY, JSON.stringify(g_persistIndex)); for (let i = 0; i < g_persist.length; i++) { const o = g_persist[i]; const r = await o.put(v); @@ -15,7 +15,10 @@ async function putPromise(o) { } async function scanPromises() { - const promises = localStorage.getItem('persist'); + const promises = localStorage.getItem(PERSIST_STORAGEKEY); + if (!promises) { + return; + } const o = JSON.parse(promises); const eList = document.createElement('ul'); eList.setAttribute('id', 'promiseList');