consolidate getIdentity & remove dups

This commit is contained in:
2024-07-11 19:43:56 -06:00
parent 7cb9e2aa52
commit 11163dfad9
8 changed files with 12 additions and 133 deletions

View File

@@ -179,18 +179,18 @@ import { IIdentifier } from "@veramo/core";
import { Component, Vue } from "vue-facing-decorator";
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
import ImageMethodDialog from "@/components/ImageMethodDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "@/constants/app";
import { accountsDB, db } from "@/db/index";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { accessToken } from "@/libs/crypto";
import * as libsUtil from "@/libs/util";
import { useAppStore } from "@/store/app";
import {
createEndorserJwtVcFromClaim,
PlanVerifiableCredential,
} from "@/libs/endorserServer";
import ImageMethodDialog from "@/components/ImageMethodDialog.vue";
import * as libsUtil from "@/libs/util";
import { useAppStore } from "@/store/app";
@Component({
components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav },
@@ -231,22 +231,6 @@ export default class NewEditProjectView extends Vue {
libsUtil = libsUtil;
public async getIdentity(activeDid: string) {
await accountsDB.open();
const account = await accountsDB.accounts
.where("did")
.equals(activeDid)
.first();
const identity = JSON.parse((account?.identity as string) || "null");
if (!identity) {
throw new Error(
"Attempted to load project records with no identifier available.",
);
}
return identity;
}
async mounted() {
await accountsDB.open();
this.numAccounts = await accountsDB.accounts.count();
@@ -524,7 +508,7 @@ export default class NewEditProjectView extends Vue {
if (this.numAccounts === 0) {
console.error("Error: there is no account.");
} else {
const identity = await this.getIdentity(this.activeDid);
const identity = await libsUtil.getIdentity(this.activeDid);
this.saveProject(identity);
}
}