mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-03 03:41:37 +00:00
DeviceReducer: do not override "state" field, make new object instead
This commit is contained in:
parent
47328d3dcc
commit
2cb9057d29
@ -187,10 +187,9 @@ const changeDevice = (state: State, device: Device | TrezorDevice, extended: Obj
|
|||||||
const authDevice = (state: State, device: TrezorDevice, deviceState: string): State => {
|
const authDevice = (state: State, device: TrezorDevice, deviceState: string): State => {
|
||||||
const affectedDevice: ?TrezorDevice = state.find(d => d.path === device.path && d.instance === device.instance);
|
const affectedDevice: ?TrezorDevice = state.find(d => d.path === device.path && d.instance === device.instance);
|
||||||
// device could already have own state from trezor-connect, do not override it
|
// device could already have own state from trezor-connect, do not override it
|
||||||
if (affectedDevice && !affectedDevice.state) {
|
if (affectedDevice && !affectedDevice.state && affectedDevice.type === 'acquired') {
|
||||||
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== affectedDevice);
|
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== affectedDevice);
|
||||||
affectedDevice.state = deviceState;
|
return otherDevices.concat([{ ...affectedDevice, state: deviceState }]);
|
||||||
return otherDevices.concat([affectedDevice]);
|
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user