1
0
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:
Szymon Lesisz 2018-10-03 19:54:22 +02:00
parent 47328d3dcc
commit 2cb9057d29

View File

@ -187,10 +187,9 @@ const changeDevice = (state: State, device: Device | TrezorDevice, extended: Obj
const authDevice = (state: State, device: TrezorDevice, deviceState: string): State => {
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
if (affectedDevice && !affectedDevice.state) {
if (affectedDevice && !affectedDevice.state && affectedDevice.type === 'acquired') {
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== affectedDevice);
affectedDevice.state = deviceState;
return otherDevices.concat([affectedDevice]);
return otherDevices.concat([{ ...affectedDevice, state: deviceState }]);
}
return state;
};