Skip to content

Commit

Permalink
Fixing account switching and adding accounts
Browse files Browse the repository at this point in the history
Issue was due to id/name mixup
  • Loading branch information
grctest committed Jan 8, 2024
1 parent 5f6221a commit d32fa5d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/components/account-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
selectedAccount.value = accounts.value[newVal];
store.dispatch(
"AccountStore/selectAccount",
{chain: accounts.value[newVal].chain, accountID: accounts.value[newVal].accountID}
{
chain: accounts.value[newVal].chain,
accountID: accounts.value[newVal].accountID
? accounts.value[newVal].accountID
: accounts.value[newVal].accountName
}
);
}
}, {immediate: true});
Expand Down
14 changes: 12 additions & 2 deletions src/components/dapps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
function fetchDapps() {
let storedDapps = [];
for (let i = 0; i < store.state.AccountStore.accountlist.length; i++) {
let apps = store.getters['OriginStore/walletAccessibleDapps'](store.state.AccountStore.accountlist[i].accountID, store.state.AccountStore.accountlist[i].chain);
let apps = store.getters['OriginStore/walletAccessibleDapps'](
store.state.AccountStore.accountlist[i].accountID
? store.state.AccountStore.accountlist[i].accountID
: store.state.AccountStore.accountlist[i].accountName,
store.state.AccountStore.accountlist[i].chain
);
if (typeof apps != 'undefined') {
storedDapps = storedDapps.concat(apps);
}
Expand All @@ -28,7 +33,12 @@
let dapps = computed(() => {
let storedDapps = [];
for (let i = 0; i < store.state.AccountStore.accountlist.length; i++) {
let apps = store.getters['OriginStore/walletAccessibleDapps'](store.state.AccountStore.accountlist[i].accountID, store.state.AccountStore.accountlist[i].chain);
let apps = store.getters['OriginStore/walletAccessibleDapps'](
store.state.AccountStore.accountlist[i].accountID
? store.state.AccountStore.accountlist[i].accountID
: store.state.AccountStore.accountlist[i].accountName,
store.state.AccountStore.accountlist[i].chain
);
if (typeof apps != 'undefined') {
storedDapps = storedDapps.concat(apps);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/popups/identityrequestpopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
if (!props.accounts || !props.accounts.length) {
return '';
}
return props.accounts[0].accountID;
return props.accounts[0].accountID
? props.accounts[0].accountID
: props.accounts[0].accountName;
});
let accountName = computed(() => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/popups/relinkrequestpopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
origin: props.request.origin,
chain: props.request.chain,
accountId: props.accounts[0].accountID
? props.accounts[0].accountID
: props.accounts[0].accountName
}
);
});
Expand All @@ -52,7 +54,9 @@
identityhash: props.request.payload.identityhash,
name: props.accounts[0].accountName,
chain: props.accounts[0].chain,
id: props.accounts[0].accountID,
id: props.accounts[0].accountID
? props.accounts[0].accountID
: props.accounts[0].accountName,
success: true
},
request: {
Expand Down
14 changes: 12 additions & 2 deletions src/store/modules/AccountStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ const actions = {
state
}, payload) {
return new Promise((resolve, reject) => {
let existingAccount = state.accountlist.find(x => x.chain == payload.account.chain && x.accountID == payload.account.accountID)
let existingAccount = state.accountlist.find(
x => x.chain == payload.account.chain &&
(x.accountID == payload.account.accountName || x.accountName === payload.account.accountName)
);

if (!existingAccount) {
for (let keytype in payload.account.keys) {
Expand Down Expand Up @@ -83,7 +86,14 @@ const actions = {
return new Promise((resolve, reject) => {
let index = -1;
for (let i = 0; i < state.accountlist.length; i++) {
if ((payload.chain == state.accountlist[i].chain) && (payload.accountID == state.accountlist[i].accountID)) {
if (
(payload.chain == state.accountlist[i].chain) &&
(
payload.accountID == state.accountlist[i].accountID ||
payload.accountID == state.accountlist[i].accountName ||
payload.accountName == state.accountlist[i].accountName
)
) {
index = i;
break;
}
Expand Down

0 comments on commit d32fa5d

Please sign in to comment.