mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-15 17:42:03 +00:00
refactored getSelectedAccount, createAccount
This commit is contained in:
parent
715da870a7
commit
27f35b097d
@ -75,8 +75,11 @@ const createAccount = (state: State, account: Account): State => {
|
|||||||
}
|
}
|
||||||
const newState: State = [...state];
|
const newState: State = [...state];
|
||||||
newState.push(account);
|
newState.push(account);
|
||||||
|
|
||||||
// sort the accounts array so the imported accounts always come before discovered accounts
|
// sort the accounts array so the imported accounts always come before discovered accounts
|
||||||
newState.sort((a, b) => b.imported - a.imported || a.index - b.index);
|
if (account.imported) {
|
||||||
|
newState.sort((a, b) => b.imported - a.imported || a.index - b.index);
|
||||||
|
}
|
||||||
return newState;
|
return newState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,18 +89,9 @@ export const getSelectedAccount = (state: State): ?Account => {
|
|||||||
? parseInt(locationState.account.substr(1), 10)
|
? parseInt(locationState.account.substr(1), 10)
|
||||||
: parseInt(locationState.account, 10);
|
: parseInt(locationState.account, 10);
|
||||||
|
|
||||||
if (isImported) {
|
|
||||||
return state.accounts.find(
|
|
||||||
a =>
|
|
||||||
a.imported === true &&
|
|
||||||
a.deviceState === device.state &&
|
|
||||||
a.index === index &&
|
|
||||||
a.network === locationState.network
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return state.accounts.find(
|
return state.accounts.find(
|
||||||
a =>
|
a =>
|
||||||
a.imported === false &&
|
a.imported === isImported &&
|
||||||
a.deviceState === device.state &&
|
a.deviceState === device.state &&
|
||||||
a.index === index &&
|
a.index === index &&
|
||||||
a.network === locationState.network
|
a.network === locationState.network
|
||||||
|
Loading…
Reference in New Issue
Block a user