forked from jsnbuchanan/crowd-funder-for-time-pwa
parameterize main identifier (to prepare the way for multiple)
This commit is contained in:
@@ -116,11 +116,12 @@
|
||||
import * as R from "ramda";
|
||||
import { Options, Vue } from "vue-class-component";
|
||||
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { accountsDB, db } from "@/db";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { AppString } from "@/constants/app";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
import { GiveServerRecord } from "@/libs/endorserServer";
|
||||
import { AppString } from "@/constants/app";
|
||||
|
||||
@Options({})
|
||||
export default class ContactsView extends Vue {
|
||||
@@ -133,16 +134,20 @@ export default class ContactsView extends Vue {
|
||||
const contactDid = this.$route.query.contactDid as string;
|
||||
this.contact = (await db.contacts.get(contactDid)) || null;
|
||||
|
||||
if (this.contact) {
|
||||
this.loadGives(this.contact);
|
||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||
const activeDid = settings?.activeDid;
|
||||
|
||||
if (activeDid && this.contact) {
|
||||
this.loadGives(activeDid, this.contact);
|
||||
}
|
||||
}
|
||||
|
||||
async loadGives(contact: Contact) {
|
||||
async loadGives(activeDid: string, contact: Contact) {
|
||||
// only load the private keys temporarily when needed
|
||||
await accountsDB.open();
|
||||
const accounts = await accountsDB.accounts.toArray();
|
||||
const identity = JSON.parse(accounts[0].identity);
|
||||
const account = R.find((acc) => acc.did === activeDid, accounts);
|
||||
const identity = JSON.parse(account?.identity || "undefined");
|
||||
|
||||
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user