From aad6b8273b096bdf1ecff400a96c58332d40a8a6 Mon Sep 17 00:00:00 2001 From: Matthew Aaron Raymer Date: Tue, 13 Dec 2022 17:47:04 +0800 Subject: [PATCH] Stil fixing database writes --- src/main.ts | 1 + src/router/index.ts | 5 ++--- src/views/AccountViewView.vue | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 01814f6..571e134 100644 --- a/src/main.ts +++ b/src/main.ts @@ -45,6 +45,7 @@ library.add( ); import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; +import { db } from "./libs/db"; createApp(App) .component("fa", FontAwesomeIcon) diff --git a/src/router/index.ts b/src/router/index.ts index e0b706e..e1af138 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -111,14 +111,12 @@ const router = createRouter({ }); router.beforeEach(async (to) => { - // redirect to start page if app is uninitialized const publicPages = ["/start", "/account", "/import-account"]; const isPublic = publicPages.includes(to.path); const appStore = useAppStore(); - console.log("to:", to.path); let return_path = "/start"; + if (isPublic) { - console.log(appStore.condition); switch (appStore.condition) { case "uninitialized": return_path = ""; @@ -139,4 +137,5 @@ router.beforeEach(async (to) => { return return_path; } }); + export default router; diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index f9e0092..8597990 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -171,7 +171,8 @@ import { useAppStore } from "../store/app"; import { useAccountStore } from "../store/account"; import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto"; import { IIdentifier } from "@veramo/core"; -import R from "ramda"; +import * as R from "ramda"; +import { db } from "../libs/db"; @Options({ components: {}, @@ -219,6 +220,18 @@ export default class AccountViewView extends Vue { privateHex, UPORT_ROOT_DERIVATION_PATH ); + console.log(newId); + db.open(); + db.accounts.add({ + did: address, + kid: newId.keys[0].kid, + kms: newId.keys[0].kms, + meta: "", + privateKeyHex: privateHex, + publicKeyHex: publicHex, + type: "Secp256k1", + }); + db.close(); //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."})) accountStore.account = JSON.stringify(newId); //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."}))