1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-28 03:08:30 +00:00

eslint fixes

This commit is contained in:
Szymon Lesisz 2018-10-02 10:57:17 +02:00
parent f59b9c31b1
commit 479486e4c9

View File

@ -131,8 +131,8 @@ const addDevice = (state: State, device: Device): State => {
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && device.features const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && device.features
&& d.features.passphrase_protection === device.features.passphrase_protection).map((d) => { && d.features.passphrase_protection === device.features.passphrase_protection).map((d) => {
const extended: Object = { connected: true, available: true }; const extended2: Object = { connected: true, available: true };
return mergeDevices(d, { ...device, ...extended }); return mergeDevices(d, { ...device, ...extended2 });
}); });
if (changedDevices.length !== affectedDevices.length) { if (changedDevices.length !== affectedDevices.length) {
changedDevices.push(newDevice); changedDevices.push(newDevice);
@ -197,7 +197,7 @@ const authDevice = (state: State, device: TrezorDevice, deviceState: string): St
// Transform JSON form local storage into State // Transform JSON form local storage into State
const devicesFromStorage = (devices: Array<TrezorDevice>): State => devices.map((device: TrezorDevice) => { const devicesFromStorage = ($devices: Array<TrezorDevice>): State => $devices.map((device: TrezorDevice) => {
const extended = { const extended = {
connected: false, connected: false,
available: false, available: false,
@ -231,14 +231,14 @@ const disconnectDevice = (state: State, device: Device): State => {
const otherDevices: State = state.filter(d => affectedDevices.indexOf(d) === -1); const otherDevices: State = state.filter(d => affectedDevices.indexOf(d) === -1);
if (affectedDevices.length > 0) { if (affectedDevices.length > 0) {
const acquiredDevices = affectedDevices.filter(d => d.features && d.state).map((d) => { const acquiredDevices = affectedDevices.filter(d => d.features && d.state).map((d) => { // eslint-disable-line arrow-body-style
if (d.type === 'acquired') { return d.type === 'acquired' ? {
d.connected = false; ...d,
d.available = false; connected: false,
d.status = 'available'; available: false,
d.path = ''; status: 'available',
} path: '',
return d; } : d;
}); });
return otherDevices.concat(acquiredDevices); return otherDevices.concat(acquiredDevices);
} }
@ -247,12 +247,18 @@ const disconnectDevice = (state: State, device: Device): State => {
}; };
const onSelectedDevice = (state: State, device: ?TrezorDevice): State => { const onSelectedDevice = (state: State, device: ?TrezorDevice): State => {
if (device) { if (!device) return state;
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== device); const otherDevices: Array<TrezorDevice> = state.filter(d => d !== device);
device.ts = new Date().getTime(); const extended = device.type === 'acquired' ? {
return otherDevices.concat([device]); ...device,
} ts: new Date().getTime(),
return state; } : {
...device,
features: null,
ts: new Date().getTime(),
};
return otherDevices.concat([extended]);
}; };
export default function devices(state: State = initialState, action: Action): State { export default function devices(state: State = initialState, action: Action): State {