From c49a54166096fb537b5b38ef09316fa3c1d1bcee Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Fri, 29 Sep 2023 13:38:04 -0400 Subject: [PATCH] Fix automation view crash when no config found (#504) --- .../RokuAutomationViewViewProvider.ts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/viewProviders/RokuAutomationViewViewProvider.ts b/src/viewProviders/RokuAutomationViewViewProvider.ts index 9d99006f..e9539fdd 100644 --- a/src/viewProviders/RokuAutomationViewViewProvider.ts +++ b/src/viewProviders/RokuAutomationViewViewProvider.ts @@ -113,23 +113,25 @@ export class RokuAutomationViewViewProvider extends BaseRdbViewProvider { return Promise.resolve(true); }); - const config = this.rokuAutomationConfigs[index]; - for (const [index, step] of config.steps.entries()) { - if (stopRunning) { - break; - } - - this.updateCurrentRunningStep(index); - switch (step.type) { - case 'sleep': - await utils.sleep(+step.value * 1000); - break; - case 'sendText': - await ecp.sendText(step.value); - break; - case 'sendKeyPress': - await ecp.sendKeyPress(step.value as any); + const config = this.rokuAutomationConfigs?.[index]; + if (config) { + for (const [index, step] of config.steps.entries()) { + if (stopRunning) { break; + } + + this.updateCurrentRunningStep(index); + switch (step.type) { + case 'sleep': + await utils.sleep(+step.value * 1000); + break; + case 'sendText': + await ecp.sendText(step.value); + break; + case 'sendKeyPress': + await ecp.sendKeyPress(step.value as any); + break; + } } }