Gaëtan Renaudeau
7 years ago
committed by
GitHub
4 changed files with 26 additions and 41 deletions
@ -0,0 +1,9 @@ |
|||
// @flow
|
|||
|
|||
import { createCommand } from 'helpers/ipc' |
|||
import { Observable } from 'rxjs' |
|||
import CommNodeHid from '@ledgerhq/hw-transport-node-hid' |
|||
|
|||
const cmd = createCommand('devices', 'listenDevices', () => Observable.create(CommNodeHid.listen)) |
|||
|
|||
export default cmd |
@ -1,24 +0,0 @@ |
|||
// @flow
|
|||
|
|||
import CommNodeHid from '@ledgerhq/hw-transport-node-hid' |
|||
import noop from 'lodash/noop' |
|||
|
|||
import type { IPCSend } from 'types/electron' |
|||
|
|||
export default (send: IPCSend) => { |
|||
CommNodeHid.listen({ |
|||
error: noop, |
|||
complete: noop, |
|||
next: async e => { |
|||
if (!e.device) { |
|||
return |
|||
} |
|||
if (e.type === 'add') { |
|||
send('device.add', e.device, { kill: false }) |
|||
} |
|||
if (e.type === 'remove') { |
|||
send('device.remove', e.device, { kill: false }) |
|||
} |
|||
}, |
|||
}) |
|||
} |
Loading…
Reference in new issue