mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Possibly fix weird race conditions
No idea how this happen at all
This commit is contained in:
parent
2bc24cc495
commit
1692637e22
2 changed files with 5 additions and 3 deletions
|
@ -27,9 +27,10 @@ function NavMenu(props) {
|
||||||
|
|
||||||
const [currentAccount, moreThanOneAccount] = useMemo(() => {
|
const [currentAccount, moreThanOneAccount] = useMemo(() => {
|
||||||
const accounts = store.local.getJSON('accounts') || [];
|
const accounts = store.local.getJSON('accounts') || [];
|
||||||
const acc = accounts.find(
|
const acc =
|
||||||
|
accounts.find(
|
||||||
(account) => account.info.id === store.session.get('currentAccount'),
|
(account) => account.info.id === store.session.get('currentAccount'),
|
||||||
);
|
) || accounts[0];
|
||||||
return [acc, accounts.length > 1];
|
return [acc, accounts.length > 1];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import store from './store';
|
||||||
|
|
||||||
export function getAccount(id) {
|
export function getAccount(id) {
|
||||||
const accounts = store.local.getJSON('accounts') || [];
|
const accounts = store.local.getJSON('accounts') || [];
|
||||||
|
if (!id) return accounts[0];
|
||||||
return accounts.find((a) => a.info.id === id) || accounts[0];
|
return accounts.find((a) => a.info.id === id) || accounts[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue