DeviceReducer: do not override "state" field, make new object instead

pull/118/head
Szymon Lesisz 6 years ago
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 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;
};

Loading…
Cancel
Save