Browse Source

Cleaned up messages and improved the accountsDB lookups

project-gives
Matthew Raymer 1 year ago
parent
commit
3471afdf25
  1. 17
      src/views/AccountViewView.vue
  2. 2
      src/views/ProjectViewView.vue

17
src/views/AccountViewView.vue

@ -274,7 +274,6 @@
<script lang="ts"> <script lang="ts">
import "dexie-export-import"; import "dexie-export-import";
import * as R from "ramda";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { useClipboard } from "@vueuse/core"; import { useClipboard } from "@vueuse/core";
@ -324,8 +323,10 @@ export default class AccountViewView extends Vue {
public async getIdentity(activeDid) { public async getIdentity(activeDid) {
await accountsDB.open(); await accountsDB.open();
const accounts = await accountsDB.accounts.toArray(); const account = await accountsDB.accounts
const account = R.find((acc) => acc.did === activeDid, accounts); .where("did")
.equals(activeDid)
.first();
const identity = JSON.parse(account?.identity || "null"); const identity = JSON.parse(account?.identity || "null");
if (!identity) { if (!identity) {
@ -362,14 +363,10 @@ export default class AccountViewView extends Vue {
return timeStr.substring(0, timeStr.indexOf("T")); return timeStr.substring(0, timeStr.indexOf("T"));
} }
async initializeCount() { async beforeCreate() {
this.numAccounts = await this.accounts.count();
}
async mounted() {
accountsDB.open(); accountsDB.open();
this.accounts = accountsDB.accounts; this.accounts = accountsDB.accounts;
await this.initializeCount(); this.numAccounts = await this.accounts.count();
} }
async created() { async created() {
@ -402,7 +399,7 @@ export default class AccountViewView extends Vue {
} catch (err) { } catch (err) {
if ( if (
err.message === err.message ===
"Attempted to load Give records with no identity available." "Attempted to load account records with no identity available."
) { ) {
this.limitsMessage = "No identity."; this.limitsMessage = "No identity.";
this.loadingLimits = false; this.loadingLimits = false;

2
src/views/ProjectViewView.vue

@ -184,7 +184,7 @@ export default class ProjectViewView extends Vue {
if (!identity) { if (!identity) {
throw new Error( throw new Error(
"Attempted to load Give records with no identity available.", "Attempted to load project records with no identity available.",
); );
} }
return identity; return identity;

Loading…
Cancel
Save