Skip to content

Commit

Permalink
chnage the way to access getDevices method
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Jan 18, 2024
1 parent 15fc98c commit e0a0584
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app-shell/src/system-info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const createUsbDevice = (device: USBDevice): UsbDevice => {
return {
vendorId: device.vendorId,
productId: device.productId,
deviceName: device.productName != null ? device.productName : 'no name',
manufacturer:
productName: device.productName != null ? device.productName : 'no name',
manufacturerName:
device.manufacturerName != null
? device.manufacturerName
: 'no manufacture',
Expand All @@ -46,8 +46,8 @@ const createUsbDevices = (devices: USBDevice[]): UsbDevice[] =>
const addDriverVersion = (device: UsbDevice): Promise<UsbDevice> => {
if (
isWindows() &&
device.manufacturer != null &&
RE_REALTEK.test(device.manufacturer)
device.manufacturerName != null &&
RE_REALTEK.test(device.manufacturerName)
) {
return getWindowsDriverVersion(device).then(windowsDriverVersion => ({
...device,
Expand Down
5 changes: 4 additions & 1 deletion app-shell/src/system-info/usb-devices.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'assert'
import execa from 'execa'
import { usb, webusb } from 'usb'
import { usb, WebUSB } from 'usb'
import { isWindows } from '../os'
import { createLogger } from '../log'

Expand All @@ -17,6 +17,9 @@ export interface UsbDeviceMonitor {
}

const log = createLogger('usb-devices')
const webusb = new WebUSB({
allowAllDevices: true,
})

export function createUsbDeviceMonitor(
options: UsbDeviceMonitorOptions = {}
Expand Down
12 changes: 10 additions & 2 deletions app/src/pages/AppSettings/AdvancedSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,11 @@ export function AdvancedSettings(): JSX.Element {
<StyledText css={TYPOGRAPHY.pSemiBold}>
{t('usb_to_ethernet_adapter_description')}
</StyledText>
<StyledText as="p">{device?.deviceName}</StyledText>
<StyledText as="p">
{device?.productName != null
? device?.productName
: t('shared:no_data')}
</StyledText>
</Flex>
<Flex
flexDirection={DIRECTION_COLUMN}
Expand All @@ -602,7 +606,11 @@ export function AdvancedSettings(): JSX.Element {
<StyledText css={TYPOGRAPHY.pSemiBold}>
{t('usb_to_ethernet_adapter_manufacturer')}
</StyledText>
<StyledText as="p">{device?.manufacturer}</StyledText>
<StyledText as="p">
{device?.manufacturerName != null
? device?.manufacturerName
: t('shared:no_data')}
</StyledText>
</Flex>
<Flex
flexDirection={DIRECTION_COLUMN}
Expand Down
4 changes: 2 additions & 2 deletions app/src/redux/system-info/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const getU2EDeviceAnalyticsProps: (
'U2E Vendor ID': device.vendorId,
'U2E Product ID': device.productId,
'U2E Serial Number': device.serialNumber,
'U2E Manufacturer': device.manufacturer,
'U2E Device Name': device.deviceName,
'U2E Manufacturer': device.manufacturerName,
'U2E Device Name': device.productName,
}

if (device.windowsDriverVersion) {
Expand Down
12 changes: 6 additions & 6 deletions app/src/redux/system-info/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
export interface UsbDevice {
vendorId: number
productId: number
deviceName: string
manufacturer: string
serialNumber: string
productName?: string
manufacturerName?: string
serialNumber?: string
windowsDriverVersion?: string | null
}

Expand All @@ -41,9 +41,9 @@ export type DriverStatus =
export interface U2EAnalyticsProps {
'U2E Vendor ID': number
'U2E Product ID': number
'U2E Serial Number': string
'U2E Device Name': string
'U2E Manufacturer': string
'U2E Serial Number'?: string
'U2E Device Name'?: string
'U2E Manufacturer'?: string
'U2E Windows Driver Version'?: string | null
[key: string]: string | number | null | undefined
}
Expand Down

0 comments on commit e0a0584

Please sign in to comment.