2023-09-05 04:19:53 +02:00
|
|
|
async function putPromise(o) {
|
|
|
|
let c = 0;
|
|
|
|
const v = JSON.stringify(o);
|
|
|
|
const h = new jsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
|
|
h.update(v);
|
|
|
|
const z = h.getHash("HEX");
|
|
|
|
g_persistIndex.push(z);
|
2023-09-05 20:01:53 +02:00
|
|
|
localStorage.setItem(PERSIST_STORAGEKEY, JSON.stringify(g_persistIndex));
|
2023-09-05 04:19:53 +02:00
|
|
|
for (let i = 0; i < g_persist.length; i++) {
|
|
|
|
const o = g_persist[i];
|
|
|
|
const r = await o.put(v);
|
|
|
|
c++;
|
|
|
|
stateChange(r, STATE.PROMISE_PERSIST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function scanPromises() {
|
2023-09-05 20:01:53 +02:00
|
|
|
const promises = localStorage.getItem(PERSIST_STORAGEKEY);
|
|
|
|
if (!promises) {
|
|
|
|
return;
|
|
|
|
}
|
2023-09-05 04:19:53 +02:00
|
|
|
const o = JSON.parse(promises);
|
|
|
|
const eList = document.createElement('ul');
|
|
|
|
eList.setAttribute('id', 'promiseList');
|
|
|
|
o.forEach(async (v) => {
|
|
|
|
const r = await g_persist[0].get(v); // replace with fadfada
|
|
|
|
const o = JSON.parse(r);
|
|
|
|
console.debug('o', o);
|
|
|
|
const eItem = document.createElement('li');
|
|
|
|
eItem.innerText = o.label;
|
|
|
|
eList.appendChild(eItem);
|
|
|
|
});
|
|
|
|
document.getElementById('promiseList').remove();
|
|
|
|
document.getElementById('promise').prepend(eList);
|
|
|
|
}
|