Fixed the crash when a custom device is added to the preview for the first time

This commit is contained in:
Manoj Vivek 2023-05-14 19:04:40 +05:30
parent ea0fb9a0b5
commit c5a52abc79

View file

@ -872,14 +872,16 @@ export const defaultDevices: Device[] = [
},
];
const customDevices: Device[] =
typeof window !== 'undefined'
const customDevices: () => Device[] = () => {
return typeof window !== 'undefined'
? window.electron.store.get('deviceManager.customDevices')
: [];
};
type DeviceMap = { [key: string]: Device };
export const getDevicesMap = (): DeviceMap => {
return [...defaultDevices, ...customDevices].reduce(
return [...defaultDevices, ...customDevices()].reduce(
(map: DeviceMap, device) => {
map[device.id] = device;
return map;