forked from trent_larson/crowd-funder-for-time-pwa
adjust didInfo so we can use DIDs and not identities, removing last of identities in memory
This commit is contained in:
@@ -82,11 +82,8 @@ export function isHiddenDid(did) {
|
|||||||
/**
|
/**
|
||||||
always returns text, maybe UNNAMED_VISIBLE or UNKNOWN_ENTITY
|
always returns text, maybe UNNAMED_VISIBLE or UNKNOWN_ENTITY
|
||||||
**/
|
**/
|
||||||
export function didInfo(did, activeDid, identifiers, contacts) {
|
export function didInfo(did, activeDid, allMyDids, contacts) {
|
||||||
const myId: IIdentifier | undefined = R.find(
|
const myId: string | undefined = R.find(R.identity, allMyDids);
|
||||||
(i) => i.did === did,
|
|
||||||
identifiers,
|
|
||||||
);
|
|
||||||
if (myId) {
|
if (myId) {
|
||||||
return "You" + (myId.did !== activeDid ? " (Alt ID)" : "");
|
return "You" + (myId.did !== activeDid ? " (Alt ID)" : "");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -293,7 +293,6 @@ import { useClipboard } from "@vueuse/core";
|
|||||||
|
|
||||||
import { AppString } from "@/constants/app";
|
import { AppString } from "@/constants/app";
|
||||||
import { db, accountsDB } from "@/db";
|
import { db, accountsDB } from "@/db";
|
||||||
import { AccountsSchema } from "@/db/tables/accounts";
|
|
||||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||||
import { accessToken } from "@/libs/crypto";
|
import { accessToken } from "@/libs/crypto";
|
||||||
import { AxiosError } from "axios/index";
|
import { AxiosError } from "axios/index";
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ import { db, accountsDB } from "@/db";
|
|||||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||||
import { accessToken } from "@/libs/crypto";
|
import { accessToken } from "@/libs/crypto";
|
||||||
import { createAndSubmitGive, didInfo } from "@/libs/endorserServer";
|
import { createAndSubmitGive, didInfo } from "@/libs/endorserServer";
|
||||||
import { Account } from "@/db/tables/accounts";
|
|
||||||
import { Contact } from "@/db/tables/contacts";
|
import { Contact } from "@/db/tables/contacts";
|
||||||
import AlertMessage from "@/components/AlertMessage";
|
import AlertMessage from "@/components/AlertMessage";
|
||||||
import QuickNav from "@/components/QuickNav";
|
import QuickNav from "@/components/QuickNav";
|
||||||
@@ -87,6 +86,7 @@ import QuickNav from "@/components/QuickNav";
|
|||||||
export default class HomeView extends Vue {
|
export default class HomeView extends Vue {
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
allContacts: Array<Contact> = [];
|
allContacts: Array<Contact> = [];
|
||||||
|
allMyDids: Array<string> = [];
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
feedAllLoaded = false;
|
feedAllLoaded = false;
|
||||||
feedData = [];
|
feedData = [];
|
||||||
@@ -130,7 +130,9 @@ export default class HomeView extends Vue {
|
|||||||
async created() {
|
async created() {
|
||||||
try {
|
try {
|
||||||
await accountsDB.open();
|
await accountsDB.open();
|
||||||
this.allAccounts = await accountsDB.accounts.toArray();
|
const allAccounts = await accountsDB.accounts.toArray();
|
||||||
|
this.allMyDids = allAccounts.map((acc) => acc.did);
|
||||||
|
|
||||||
await db.open();
|
await db.open();
|
||||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||||
this.apiServer = settings?.apiServer || "";
|
this.apiServer = settings?.apiServer || "";
|
||||||
@@ -227,16 +229,13 @@ export default class HomeView extends Vue {
|
|||||||
if (claim.claim) {
|
if (claim.claim) {
|
||||||
claim = claim.claim;
|
claim = claim.claim;
|
||||||
}
|
}
|
||||||
await accountsDB.open();
|
|
||||||
const allAccounts = await accountsDB.accounts.toArray();
|
|
||||||
|
|
||||||
// agent.did is for legacy data, before March 2023
|
// agent.did is for legacy data, before March 2023
|
||||||
const giverDid =
|
const giverDid =
|
||||||
claim.agent?.identifier || claim.agent?.did || giveRecord.issuer;
|
claim.agent?.identifier || claim.agent?.did || giveRecord.issuer;
|
||||||
const giverInfo = didInfo(
|
const giverInfo = didInfo(
|
||||||
giverDid,
|
giverDid,
|
||||||
this.activeDid,
|
this.activeDid,
|
||||||
allAccounts,
|
this.allMyDids,
|
||||||
this.allContacts,
|
this.allContacts,
|
||||||
);
|
);
|
||||||
const gaveAmount = claim.object?.amountOfThisGood
|
const gaveAmount = claim.object?.amountOfThisGood
|
||||||
@@ -249,7 +248,7 @@ export default class HomeView extends Vue {
|
|||||||
didInfo(
|
didInfo(
|
||||||
gaveRecipientId,
|
gaveRecipientId,
|
||||||
this.activeDid,
|
this.activeDid,
|
||||||
allAccounts,
|
this.allMyDids,
|
||||||
this.allContacts,
|
this.allContacts,
|
||||||
)
|
)
|
||||||
: "";
|
: "";
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ export default class AccountViewView extends Vue {
|
|||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await accountsDB.open();
|
|
||||||
const mnemonic = generateSeed();
|
const mnemonic = generateSeed();
|
||||||
// address is 0x... ETH address, without "did:eth:"
|
// address is 0x... ETH address, without "did:eth:"
|
||||||
const [address, privateHex, publicHex, derivationPath] =
|
const [address, privateHex, publicHex, derivationPath] =
|
||||||
@@ -58,6 +57,8 @@ export default class AccountViewView extends Vue {
|
|||||||
|
|
||||||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
||||||
const identity = JSON.stringify(newId);
|
const identity = JSON.stringify(newId);
|
||||||
|
|
||||||
|
await accountsDB.open();
|
||||||
await accountsDB.accounts.add({
|
await accountsDB.accounts.add({
|
||||||
dateCreated: new Date().toISOString(),
|
dateCreated: new Date().toISOString(),
|
||||||
derivationPath: derivationPath,
|
derivationPath: derivationPath,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<fa icon="user" class="fa-fw text-slate-400"></fa>
|
<fa icon="user" class="fa-fw text-slate-400"></fa>
|
||||||
<span>{{
|
<span>{{
|
||||||
didInfo(give.agentDid, activeDid, accounts, allContacts)
|
didInfo(give.agentDid, activeDid, allMyDids, allContacts)
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2" v-if="give.amount">
|
<div class="flex gap-2" v-if="give.amount">
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<fa icon="user" class="fa-fw text-slate-400"></fa>
|
<fa icon="user" class="fa-fw text-slate-400"></fa>
|
||||||
<span>{{
|
<span>{{
|
||||||
didInfo(give.agentDid, activeDid, accounts, allContacts)
|
didInfo(give.agentDid, activeDid, allMyDids, allContacts)
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2" v-if="give.amount">
|
<div class="flex gap-2" v-if="give.amount">
|
||||||
@@ -183,6 +183,7 @@ export default class ProjectViewView extends Vue {
|
|||||||
activeDid = "";
|
activeDid = "";
|
||||||
alertMessage = "";
|
alertMessage = "";
|
||||||
alertTitle = "";
|
alertTitle = "";
|
||||||
|
allMyDids: Array<string> = [];
|
||||||
allContacts: Array<Contact> = [];
|
allContacts: Array<Contact> = [];
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
description = "";
|
description = "";
|
||||||
@@ -191,17 +192,11 @@ export default class ProjectViewView extends Vue {
|
|||||||
givesByThis: Array<GiveServerRecord> = [];
|
givesByThis: Array<GiveServerRecord> = [];
|
||||||
name = "";
|
name = "";
|
||||||
issuer = "";
|
issuer = "";
|
||||||
numAccounts = 0;
|
|
||||||
projectId = localStorage.getItem("projectId") || ""; // handle ID
|
projectId = localStorage.getItem("projectId") || ""; // handle ID
|
||||||
timeSince = "";
|
timeSince = "";
|
||||||
truncatedDesc = "";
|
truncatedDesc = "";
|
||||||
truncateLength = 40;
|
truncateLength = 40;
|
||||||
|
|
||||||
async beforeCreate() {
|
|
||||||
await accountsDB.open();
|
|
||||||
this.numAccounts = (await accountsDB.accounts?.count()) || 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
await db.open();
|
await db.open();
|
||||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||||
@@ -209,9 +204,11 @@ export default class ProjectViewView extends Vue {
|
|||||||
this.apiServer = settings?.apiServer || "";
|
this.apiServer = settings?.apiServer || "";
|
||||||
this.allContacts = await db.contacts.toArray();
|
this.allContacts = await db.contacts.toArray();
|
||||||
|
|
||||||
this.accounts = accountsDB.accounts;
|
await accountsDB.open();
|
||||||
const accountsArr = await this.accounts?.toArray();
|
const accounts = accountsDB.accounts;
|
||||||
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
const accountsArr = await accounts?.toArray();
|
||||||
|
this.allMyDids = accountsArr.map((acc) => acc.did);
|
||||||
|
const account = accountsArr?.find((acc) => acc.did === this.activeDid);
|
||||||
const identity = JSON.parse(account?.identity || "null");
|
const identity = JSON.parse(account?.identity || "null");
|
||||||
this.LoadProject(identity);
|
this.LoadProject(identity);
|
||||||
}
|
}
|
||||||
@@ -250,8 +247,8 @@ export default class ProjectViewView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Isn't there a better way to make this available to the template?
|
// Isn't there a better way to make this available to the template?
|
||||||
didInfo(did, activeDid, identities, contacts) {
|
didInfo(did, activeDid, dids, contacts) {
|
||||||
return didInfo(did, activeDid, identities, contacts);
|
return didInfo(did, activeDid, dids, contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
expandText() {
|
expandText() {
|
||||||
|
|||||||
Reference in New Issue
Block a user