Check wheter 'device.features' are defined

pull/2/merge^2
Vasek Mlejnsky 6 years ago
parent 3082c7fdd7
commit 28285754e2

@ -330,13 +330,14 @@ export const deviceDisconnect = (device: Device): AsyncAction => async (dispatch
dispatch(DiscoveryActions.stop(selected));
}
const instances = getState().devices.filter(d => d.features && d.state && !d.remember && d.features.device_id === device.features.device_id);
if (instances.length > 0) {
dispatch({
type: CONNECT.REMEMBER_REQUEST,
device: instances[0],
instances,
});
const instances = getState().devices.filter(d => d.features && d.state && !d.remember && device.features && d.features.device_id === device.features.device_id);
if (instances.length > 0) {
dispatch({
type: CONNECT.REMEMBER_REQUEST,
device: instances[0],
instances,
});
}
}
}
};

@ -75,7 +75,9 @@ export const toggleDeviceDropdown = (opened: boolean): WalletAction => ({
export const clearUnavailableDevicesData = (prevState: State, device: Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
if (!device.features) return;
const affectedDevices = prevState.devices.filter(d => d.features
const affectedDevices = prevState.devices.filter(d =>
d.features
&& device.features
&& d.features.device_id === device.features.device_id
&& d.features.passphrase_protection !== device.features.passphrase_protection);

@ -112,7 +112,7 @@ const addDevice = (state: State, device: Device): State => {
// changedDevices.push(newDevice);
// }
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && d.features.passphrase_protection === device.features.passphrase_protection).map(d => mergeDevices(d, { ...device, connected: true, available: true }));
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && device.features && d.features.passphrase_protection === device.features.passphrase_protection).map(d => mergeDevices(d, { ...device, connected: true, available: true }));
if (changedDevices.length !== affectedDevices.length) {
changedDevices.push(newDevice);
}
@ -150,7 +150,7 @@ const changeDevice = (state: State, device: Device): State => {
// find devices with the same device_id and passphrase_protection settings
// or devices with the same path (TODO: should be that way?)
const affectedDevices: Array<TrezorDevice> = state.filter(d => (d.features && d.features.device_id === device.features.device_id && d.features.passphrase_protection === device.features.passphrase_protection)
const affectedDevices: Array<TrezorDevice> = state.filter(d => (d.features && device.features && d.features.device_id === device.features.device_id && d.features.passphrase_protection === device.features.passphrase_protection)
|| (d.features && d.path.length > 0 && d.path === device.path));
const otherDevices: Array<TrezorDevice> = state.filter(d => affectedDevices.indexOf(d) === -1);

Loading…
Cancel
Save