Serialize toolbox writes and preserve concurrent edits
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
This commit is contained in:
parent
7521d50626
commit
a4cf633ab4
12 changed files with 381 additions and 320 deletions
|
|
@ -108,13 +108,18 @@ export async function setToolboxSnapshot(toolboxes, links, moduleData) {
|
|||
const transaction = db.transaction([KV_STORE, MODULE_STORE], "readwrite");
|
||||
const kv = transaction.objectStore(KV_STORE);
|
||||
const modules = transaction.objectStore(MODULE_STORE);
|
||||
kv.put(toolboxes, "toolboxes");
|
||||
kv.put(links, "links");
|
||||
modules.clear();
|
||||
Object.entries(moduleData || {}).forEach(([key, data]) => modules.put({ key, data }));
|
||||
transaction.oncomplete = () => resolve();
|
||||
transaction.onerror = () => reject(transaction.error);
|
||||
transaction.onabort = () => reject(transaction.error);
|
||||
try {
|
||||
kv.put(toolboxes, "toolboxes");
|
||||
kv.put(links, "links");
|
||||
modules.clear();
|
||||
Object.entries(moduleData || {}).forEach(([key, data]) => modules.put({ key, data }));
|
||||
} catch (error) {
|
||||
transaction.abort();
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue