diff --git a/.vscode/settings.json b/.vscode/settings.json index 31b20d1..89d2e29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "files.eol": "\n", "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "editor.rulers": [ 140 ], "eslint.enable": true diff --git a/src/utils.ts b/src/utils.ts index eabd046..7876ea7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,8 +2,12 @@ import { Color, OpenRgbColor, RgbDevice, RgbDeviceStates } from './rgb'; /** Gets the RGB color that is set on the provided device */ export function getDeviceLedRgbColor(device: RgbDevice): Color { - const ledColor: OpenRgbColor = device.colors[0]; - const ledRgb: Color = [ledColor.red, ledColor.green, ledColor.blue]; + const ledColor: OpenRgbColor = device?.colors?.[0]; + const ledRgb: Color = [ + ledColor?.red ?? 0, + ledColor?.green ?? 0, + ledColor?.blue ?? 0, + ]; return ledRgb; }