diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue
index 8a1d3e8..aaa3db3 100644
--- a/src/views/IdentitySwitcherView.vue
+++ b/src/views/IdentitySwitcherView.vue
@@ -25,12 +25,15 @@
-
-
Givenname Surname
+
- ID: did:peer:lk451kl3kl45kj41
+ ID: {{ ident.did }}
@@ -44,8 +47,9 @@
Add Another Identity…
No Identity
@@ -68,10 +72,23 @@ import QuickNav from "@/components/QuickNav";
@Component({ components: { AlertMessage, QuickNav } })
export default class IdentitySwitcherView extends Vue {
Constants = AppString;
- private accounts: AccountsSchema;
+ public accounts: AccountsSchema;
public activeDid;
public firstName;
public lastName;
+ public alertTitle;
+ public alertMessage;
+ public otherIdentities = [];
+
+ public async getIdentity(activeDid) {
+ await accountsDB.open();
+ const account = await accountsDB.accounts
+ .where("did")
+ .equals(activeDid)
+ .first();
+ const identity = JSON.parse(account?.identity || "null");
+ return identity;
+ }
async created() {
try {
@@ -86,14 +103,19 @@ export default class IdentitySwitcherView extends Vue {
const identity = await this.getIdentity(this.activeDid);
- this.publicHex = identity.keys[0].publicKeyHex;
- this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64");
- this.derivationPath = identity.keys[0].meta.derivationPath;
-
- db.settings.update(MASTER_SETTINGS_KEY, {
- activeDid: identity.did,
- });
- this.checkLimits();
+ if (identity) {
+ db.settings.update(MASTER_SETTINGS_KEY, {
+ activeDid: identity.did,
+ });
+ }
+ await accountsDB.open();
+ const accounts = await accountsDB.accounts.toArray();
+ for (let n = 0; n < accounts.length; n++) {
+ const did = JSON.parse(accounts[n].identity)["did"];
+ if (did && this.activeDid !== did) {
+ this.otherIdentities.push({ did: did });
+ }
+ }
} catch (err) {
if (
err.message ===
@@ -113,31 +135,24 @@ export default class IdentitySwitcherView extends Vue {
}
}
- async switchAccount(accountNum: number) {
+ async switchAccount(did: string) {
// 0 means none
- if (accountNum === 0) {
- await db.open();
- db.settings.update(MASTER_SETTINGS_KEY, {
- activeDid: undefined,
- });
- this.activeDid = "";
- this.derivationPath = "";
- this.publicHex = "";
- this.publicBase64 = "";
- } else {
- await accountsDB.open();
- const accounts = await accountsDB.accounts.toArray();
- const account = accounts[accountNum - 1];
-
- await db.open();
- db.settings.update(MASTER_SETTINGS_KEY, {
- activeDid: account.did,
- });
-
- this.activeDid = account.did;
- this.derivationPath = account.derivationPath;
- this.publicHex = account.publicKeyHex;
- this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64");
+ if (did === "0") {
+ did = undefined;
+ }
+ await db.open();
+ db.settings.update(MASTER_SETTINGS_KEY, {
+ activeDid: did,
+ });
+ this.activeDid = did;
+ this.otherIdentities = [];
+ await accountsDB.open();
+ const accounts = await accountsDB.accounts.toArray();
+ for (let n = 0; n < accounts.length; n++) {
+ const did = JSON.parse(accounts[n].identity)["did"];
+ if (did && this.activeDid !== did) {
+ this.otherIdentities.push({ did: did });
+ }
}
}
}