From 3bd55f3ad291a5933a18b35084572537339c3243 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Sat, 8 Jul 2023 18:31:12 +0800 Subject: [PATCH] More cleanup and application of new db loading --- src/views/ContactAmountsView.vue | 14 ++++++++++-- src/views/ContactsView.vue | 2 +- src/views/HomeView.vue | 15 +++++++++--- src/views/NewEditProjectView.vue | 39 +++++++++++++++----------------- src/views/ProjectViewView.vue | 18 +++++++++++---- src/views/ProjectsView.vue | 39 ++++++++++++++++++++++---------- 6 files changed, 83 insertions(+), 44 deletions(-) diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 11f327a..02a9e22 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -142,11 +142,21 @@ export default class ContactsView extends Vue { giveRecords: Array = []; alertTitle = ""; alertMessage = ""; + accounts: AccountsSchema; + numAccounts = 0; + + async beforeCreate() { + accountsDB.open(); + this.accounts = accountsDB.accounts; + this.numAccounts = await this.accounts.count(); + } public async getIdentity(activeDid) { await accountsDB.open(); - const accounts = await accountsDB.accounts.toArray(); - const account = R.find((acc) => acc.did === activeDid, accounts); + const account = await accountsDB.accounts + .where("did") + .equals(activeDid) + .first(); const identity = JSON.parse(account?.identity || "null"); if (!identity) { diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index fb81441..21f352f 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -578,7 +578,7 @@ export default class ContactsView extends Vue { } async onClickAddGive(fromDid: string, toDid: string): Promise { - const identity = this.getIdentity(this.activeDid); + const identity = await this.getIdentity(this.activeDid); // if they have unconfirmed amounts, ask to confirm those first if (toDid == identity?.did && this.givenToMeUnconfirmed[fromDid] > 0) { diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index a289f7c..336433e 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -71,7 +71,6 @@