|
|
|
@ -90,8 +90,16 @@ const createAccount = (state: State, account: Account): State => {
|
|
|
|
|
return newState;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const removeAccounts = (state: State, device: TrezorDevice): State =>
|
|
|
|
|
state.filter(account => account.deviceState !== device.state);
|
|
|
|
|
const removeAccounts = (
|
|
|
|
|
state: State,
|
|
|
|
|
device: TrezorDevice,
|
|
|
|
|
keepImportedAccounts = false
|
|
|
|
|
): State => {
|
|
|
|
|
if (keepImportedAccounts) {
|
|
|
|
|
return state.filter(account => account.deviceState !== device.state || account.imported);
|
|
|
|
|
}
|
|
|
|
|
return state.filter(account => account.deviceState !== device.state);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const clear = (state: State, devices: Array<TrezorDevice>): State => {
|
|
|
|
|
let newState: State = [...state];
|
|
|
|
@ -121,9 +129,11 @@ export default (state: State = initialState, action: Action): State => {
|
|
|
|
|
case CONNECT.FORGET:
|
|
|
|
|
case CONNECT.FORGET_SINGLE:
|
|
|
|
|
case CONNECT.FORGET_SILENT:
|
|
|
|
|
case CONNECT.RECEIVE_WALLET_TYPE:
|
|
|
|
|
return removeAccounts(state, action.device);
|
|
|
|
|
|
|
|
|
|
case CONNECT.RECEIVE_WALLET_TYPE:
|
|
|
|
|
return removeAccounts(state, action.device, true); // removes all accounts except imported ones
|
|
|
|
|
|
|
|
|
|
case WALLET.CLEAR_UNAVAILABLE_DEVICE_DATA:
|
|
|
|
|
return clear(state, action.devices);
|
|
|
|
|
|
|
|
|
|