mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 01:08:27 +00:00
added new field "useEmptyPassphrase" to TrezorDevice object
This commit is contained in:
parent
f32c2d351d
commit
109c93aff8
@ -56,6 +56,7 @@ export type AcquiredDevice = $Exact<{
|
||||
status: DeviceStatus,
|
||||
+mode: DeviceMode,
|
||||
state: ?string,
|
||||
useEmptyPassphrase: boolean,
|
||||
|
||||
remember: boolean; // device should be remembered
|
||||
connected: boolean; // device is connected
|
||||
@ -73,6 +74,7 @@ export type UnknownDevice = $Exact<{
|
||||
+label: string,
|
||||
+features: null,
|
||||
state: ?string,
|
||||
useEmptyPassphrase: boolean,
|
||||
|
||||
remember: boolean; // device should be remembered
|
||||
connected: boolean; // device is connected
|
||||
|
@ -39,6 +39,7 @@ const mergeDevices = (current: TrezorDevice, upcoming: Device | TrezorDevice): T
|
||||
instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName,
|
||||
state: current.state,
|
||||
ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts,
|
||||
useEmptyPassphrase: typeof upcoming.useEmptyPassphrase === 'boolean' ? upcoming.useEmptyPassphrase : current.useEmptyPassphrase,
|
||||
};
|
||||
|
||||
if (upcoming.type === 'acquired') {
|
||||
@ -89,6 +90,7 @@ const addDevice = (state: State, device: Device): State => {
|
||||
instanceLabel: device.label,
|
||||
instanceName: null,
|
||||
ts: new Date().getTime(),
|
||||
useEmptyPassphrase: true,
|
||||
};
|
||||
|
||||
|
||||
@ -260,6 +262,22 @@ const onSelectedDevice = (state: State, device: ?TrezorDevice): State => {
|
||||
return otherDevices.concat([extended]);
|
||||
};
|
||||
|
||||
const onChangeWalletType = (state: State, device: TrezorDevice, hidden: boolean): State => {
|
||||
const affectedDevices: State = state.filter(d => d.path === device.path || (d.features && device.features && d.features.device_id === device.features.device_id));
|
||||
const otherDevices: State = state.filter(d => affectedDevices.indexOf(d) === -1);
|
||||
if (affectedDevices.length > 0) {
|
||||
const changedDevices = affectedDevices.map((d) => { // eslint-disable-line arrow-body-style
|
||||
return d.type === 'acquired' ? {
|
||||
...d,
|
||||
state: null,
|
||||
useEmptyPassphrase: !hidden,
|
||||
} : d;
|
||||
});
|
||||
return otherDevices.concat(changedDevices);
|
||||
}
|
||||
return state;
|
||||
};
|
||||
|
||||
export default function devices(state: State = initialState, action: Action): State {
|
||||
switch (action.type) {
|
||||
case CONNECT.DEVICE_FROM_STORAGE:
|
||||
@ -296,6 +314,9 @@ export default function devices(state: State = initialState, action: Action): St
|
||||
case WALLET.SET_SELECTED_DEVICE:
|
||||
return onSelectedDevice(state, action.device);
|
||||
|
||||
case CONNECT.RECEIVE_WALLET_TYPE:
|
||||
return onChangeWalletType(state, action.device, action.hidden);
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user