mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-09 16:58:32 +01:00
chore(connect): improve type for releases and pick model
This commit is contained in:
@@ -17,12 +17,10 @@ import type {
|
||||
} from '../types';
|
||||
import { DeviceModelInternal } from '../types';
|
||||
|
||||
const releases: Record<keyof typeof DeviceModelInternal, FirmwareRelease[]> = {
|
||||
[DeviceModelInternal.T1B1]: [],
|
||||
[DeviceModelInternal.T2T1]: [],
|
||||
[DeviceModelInternal.T2B1]: [],
|
||||
[DeviceModelInternal.T3T1]: [],
|
||||
};
|
||||
const releases = Object.values(DeviceModelInternal).reduce(
|
||||
(acc, key) => ({ ...acc, [key]: [] }),
|
||||
{} as Record<keyof typeof DeviceModelInternal, FirmwareRelease[]>,
|
||||
);
|
||||
|
||||
export const parseFirmware = (json: any, deviceModel: DeviceModelInternal) => {
|
||||
Object.keys(json).forEach(key => {
|
||||
|
||||
@@ -2,13 +2,7 @@ import { DeviceModelInternal } from '@trezor/connect';
|
||||
|
||||
export const pickByDeviceModel = <Type>(
|
||||
deviceModelInternal: DeviceModelInternal | undefined,
|
||||
options: {
|
||||
default: Type;
|
||||
[DeviceModelInternal.T1B1]?: Type;
|
||||
[DeviceModelInternal.T2T1]?: Type;
|
||||
[DeviceModelInternal.T2B1]?: Type;
|
||||
[DeviceModelInternal.T3T1]?: Type;
|
||||
},
|
||||
options: { default: Type } & Partial<Record<DeviceModelInternal, Type>>,
|
||||
): Type => {
|
||||
if (!deviceModelInternal || typeof options[deviceModelInternal] === 'undefined') {
|
||||
return options.default;
|
||||
|
||||
Reference in New Issue
Block a user