Fix set initial load

This commit is contained in:
hppeng 2022-06-26 05:18:23 -07:00
parent 1303c959b1
commit 21773ab52d
2 changed files with 10 additions and 3 deletions

View file

@ -1,4 +1,5 @@
let atree_map;
let atree_head;
let atree_connectors_map;
function construct_AT(elem, tree) {
console.log("constructing ability tree UI");
@ -25,6 +26,11 @@ function construct_AT(elem, tree) {
// create rows if not exist
let missing_rows = [node.display.row];
if (node.parents.length == 0) {
// Assuming there is only one head.
atree_head = node;
}
for (let parent of node.parents) {
missing_rows.push(tree.find(object => {return object.display_name === parent;}).display.row);
}

View file

@ -103,7 +103,7 @@ async function load() {
let url = baseUrl + "/compress.json?"+new Date();
let result = await (await fetch(url)).json();
items = result.items;
sets = result.sets;
let sets_ = result.sets;
let add_tx = db.transaction(['item_db', 'set_db'], 'readwrite');
add_tx.onabort = function(e) {
@ -121,8 +121,9 @@ async function load() {
add_promises.push(req);
}
let sets_store = add_tx.objectStore('set_db');
for (const set in sets) {
add_promises.push(sets_store.add(sets[set], set));
for (const set in sets_) {
add_promises.push(sets_store.add(sets_[set], set));
sets.set(set, sets_[set]);
}
add_promises.push(add_tx.complete);