diff --git a/src/db/index.ts b/src/db/index.ts index cc6105b..be9d9f4 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -19,17 +19,14 @@ const schema = Object.assign({}, accountsSchema); * Needed to enable a special webpack setting to allow *await* below: * https://stackoverflow.com/questions/72474803/error-the-top-level-await-experiment-is-not-enabled-set-experiments-toplevelaw */ -// if db already made, skip creation -const exists = await BaseDexie.exists("kickStarter"); -if (exists == false) { - // create password and place password in localStorage - const secret = - localStorage.getItem("secret") || Encryption.createRandomEncryptionKey(); - if (localStorage.getItem("secret") == null) { - localStorage.setItem("secret", secret); - } - console.log(secret); - encrypted(db, { secretKey: secret }); - db.version(1).stores(schema); +// create password and place password in localStorage +const secret = + localStorage.getItem("secret") || Encryption.createRandomEncryptionKey(); + +if (localStorage.getItem("secret") == null) { + localStorage.setItem("secret", secret); } +console.log(secret); +encrypted(db, { secretKey: secret }); +db.version(1).stores(schema); diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 68efbe5..ccfcd1c 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -225,7 +225,7 @@ export default class AccountViewView extends Vue { ); try { await db.open(); - const num_accounts = await db._allTables.accounts.count(); + const num_accounts = await db.accounts.count(); if (num_accounts === 0) { console.log("..."); await db._allTables.accounts.add({ @@ -235,7 +235,7 @@ export default class AccountViewView extends Vue { dateCreated: new Date().getTime(), }); } - const accounts = await db._allTables.accounts.toArray(); + const accounts = await db.accounts.toArray(); console.log(accounts[0]); const identity = JSON.parse(accounts[0].identity); @@ -244,8 +244,9 @@ export default class AccountViewView extends Vue { //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."})) //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) - } catch { + } catch (err) { console.log("Error!"); + console.log(err); } } }