From 594b874ed232f232d382836c4a767d12ee0523d2 Mon Sep 17 00:00:00 2001 From: vered constantin Date: Wed, 20 Mar 2024 09:30:02 +0200 Subject: [PATCH] fix: exception in dispose (#826) --- .../src/panels/AbstractWebviewPanel.ts | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/panels/AbstractWebviewPanel.ts b/packages/backend/src/panels/AbstractWebviewPanel.ts index 48768ab90..03d672eb9 100644 --- a/packages/backend/src/panels/AbstractWebviewPanel.ts +++ b/packages/backend/src/panels/AbstractWebviewPanel.ts @@ -114,17 +114,19 @@ export abstract class AbstractWebviewPanel { // When user clicks "Finish" the generated has ended and the success/failure result will be set in "GENERATOR_COMPLETED". // If it has not been ended, "GENERATOR_COMPLETED" will be undefined. if (yeomanui && isGeneratorCompleted === undefined) { - const promptItems: any = get(yeomanui, "gen.prompts.items") ?? []; - const currentPromptCount = yeomanui.promptCount; - const numOfPromopts = promptItems.length; - const wizardStepName = promptItems[currentPromptCount - 1].name; - AnalyticsWrapper.updateGeneratorClosedManually( - yeomanui.generatorName ?? "", - wizardStepName, - currentPromptCount, - numOfPromopts, - this.logger, - ); + const promptItems: any = get(yeomanui, "gen.prompts.items"); + if (promptItems) { + const currentPromptCount = yeomanui.promptCount; + const numOfPromopts = promptItems.length; + const wizardStepName = promptItems[currentPromptCount - 1]?.name; + AnalyticsWrapper.updateGeneratorClosedManually( + yeomanui.generatorName ?? "", + wizardStepName, + currentPromptCount, + numOfPromopts, + this.logger, + ); + } } // Clean up our resources