diff --git a/load.js b/load.js index 8cddd6b..26de2a8 100644 --- a/load.js +++ b/load.js @@ -3,6 +3,7 @@ const DB_VERSION = 38; let db; let reload = false; +let load_complete = false; let items; let sets; let itemMap; @@ -41,12 +42,13 @@ async function load_local(init_func) { console.log("Successfully read local set db."); //console.log(sets); init_maps(); - console.log(init_func); init_func(); + load_complete = true; } } } await get_tx.complete; + db.close(); } /* @@ -112,12 +114,13 @@ async function load(init_func) { Promise.all(add_promises).then((values) => { init_maps(); init_func(); + load_complete = true; }); // DB not closed? idfk man } function load_init(init_func) { - if (db) { + if (load_complete) { console.log("Item db already loaded, skipping load sequence"); init_func(); return; diff --git a/load_ing.js b/load_ing.js index e8a1b69..b1304fa 100644 --- a/load_ing.js +++ b/load_ing.js @@ -4,6 +4,7 @@ const ING_DB_VERSION = 5; let idb; let ireload = false; +let iload_complete = false; let ings; let recipes; @@ -39,11 +40,12 @@ async function ing_load_local(init_func) { console.log("Successfully read local recipe db."); recipes = request4.result; init_ing_maps(); + init_func(); + iload_complete = true; } } await get_tx.complete; idb.close(); - init_func(); } function clean_ing(ing) { @@ -98,12 +100,13 @@ async function load_ings(init_func) { Promise.all(add_promises).then((values) => { init_ing_maps(); init_func(); + iload_complete = true; }); // DB not closed? idfk man } function load_ing_init(init_func) { - if (idb) { + if (iload_complete) { console.log("Ingredient db already loaded, skipping load sequence"); init_func(); return;