|
@ -14,7 +14,7 @@ import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
|
|
import { GENUINE_TIMEOUT, DEVICE_INFOS_TIMEOUT, GENUINE_CACHE_DELAY } from 'config/constants' |
|
|
import { GENUINE_TIMEOUT, DEVICE_INFOS_TIMEOUT, GENUINE_CACHE_DELAY } from 'config/constants' |
|
|
|
|
|
|
|
|
import { getCurrentDevice } from 'reducers/devices' |
|
|
import { getCurrentDevice } from 'reducers/devices' |
|
|
import { createCustomErrorClass } from 'helpers/errors' |
|
|
import { CantOpenDevice, DeviceNotGenuineError, DeviceGenuineSocketEarlyClose } from 'config/errors' |
|
|
|
|
|
|
|
|
import getDeviceInfo from 'commands/getDeviceInfo' |
|
|
import getDeviceInfo from 'commands/getDeviceInfo' |
|
|
import getIsGenuine from 'commands/getIsGenuine' |
|
|
import getIsGenuine from 'commands/getIsGenuine' |
|
@ -26,9 +26,6 @@ import IconUsb from 'icons/Usb' |
|
|
import IconHome from 'icons/Home' |
|
|
import IconHome from 'icons/Home' |
|
|
import IconCheck from 'icons/Check' |
|
|
import IconCheck from 'icons/Check' |
|
|
|
|
|
|
|
|
const DeviceNotGenuineError = createCustomErrorClass('DeviceNotGenuine') |
|
|
|
|
|
const DeviceGenuineSocketEarlyClose = createCustomErrorClass('DeviceGenuineSocketEarlyClose') |
|
|
|
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
|
t: T, |
|
|
t: T, |
|
|
onFail?: Error => void, |
|
|
onFail?: Error => void, |
|
@ -59,11 +56,18 @@ class GenuineCheck extends PureComponent<Props> { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
checkDashboardInteractionHandler = ({ device }: { device: Device }) => |
|
|
checkDashboardInteractionHandler = ({ device }: { device: Device }) => |
|
|
createCancelablePolling(() => |
|
|
createCancelablePolling( |
|
|
getDeviceInfo |
|
|
() => |
|
|
.send({ devicePath: device.path }) |
|
|
getDeviceInfo |
|
|
.pipe(timeout(DEVICE_INFOS_TIMEOUT)) |
|
|
.send({ devicePath: device.path }) |
|
|
.toPromise(), |
|
|
.pipe(timeout(DEVICE_INFOS_TIMEOUT)) |
|
|
|
|
|
.toPromise(), |
|
|
|
|
|
{ |
|
|
|
|
|
shouldThrow: (err: Error) => { |
|
|
|
|
|
const isCantOpenDevice = err instanceof CantOpenDevice |
|
|
|
|
|
return isCantOpenDevice |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
checkGenuineInteractionHandler = async ({ |
|
|
checkGenuineInteractionHandler = async ({ |
|
|