fix: add await to new getAccounts() call

This commit is contained in:
tamaina 2021-06-30 00:18:52 +09:00
parent a1c45e85cf
commit a3ef6d9bf2
2 changed files with 8 additions and 8 deletions

View file

@ -48,10 +48,10 @@ export default defineComponent({
title: this.$ts.accounts,
icon: 'fas fa-users',
},
storedAccounts: getAccounts().filter(x => x.id !== this.$i.id),
storedAccounts: getAccounts().then(accounts => accounts.filter(x => x.id !== this.$i.id)),
accounts: null,
init: () => os.api('users/show', {
userIds: this.storedAccounts.map(x => x.id)
init: async () => os.api('users/show', {
userIds: (await this.storedAccounts).map(x => x.id)
}).then(accounts => {
this.accounts = accounts;
}),
@ -104,8 +104,8 @@ export default defineComponent({
}, 'closed');
},
switchAccount(account: any) {
const storedAccounts = getAccounts();
async switchAccount(account: any) {
const storedAccounts = await getAccounts();
const token = storedAccounts.find(x => x.id === account.id).token;
this.switchAccountWithToken(token);
},

View file

@ -121,7 +121,7 @@ export default defineComponent({
},
async openAccountMenu(ev) {
const storedAccounts = getAccounts().filter(x => x.id !== this.$i.id);
const storedAccounts = (await getAccounts()).filter(x => x.id !== this.$i.id);
const accountsPromise = os.api('users/show', { userIds: storedAccounts.map(x => x.id) });
const accountItemPromises = storedAccounts.map(a => new Promise(res => {
@ -181,8 +181,8 @@ export default defineComponent({
}, 'closed');
},
switchAccount(account: any) {
const storedAccounts = getAccounts();
async switchAccount(account: any) {
const storedAccounts = await getAccounts();
const token = storedAccounts.find(x => x.id === account.id).token;
this.switchAccountWithToken(token);
},