From ce24429e108d6f5891621d86c150f6bf77428825 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Tue, 1 Nov 2022 11:19:34 -0400 Subject: [PATCH] Updates completed steps on home --- src/webviews/apps/home/home.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/webviews/apps/home/home.ts b/src/webviews/apps/home/home.ts index 6ffda1d..69ec34f 100644 --- a/src/webviews/apps/home/home.ts +++ b/src/webviews/apps/home/home.ts @@ -153,13 +153,21 @@ export class HomeApp extends App { $headerContent.setAttribute('image', avatar); } $headerContent.setAttribute('name', subscription.account?.name ?? ''); - const steps = this.$steps?.length; - let completed = completedSteps?.length; - if (forceShowPlus && completedSteps != null && this.$steps != null && steps === completed) { - completed -= 1; + + const steps = this.$steps?.length ?? 0; + let completed = completedSteps?.length ?? 0; + if (steps > 0 && completed > 0) { + const stepIds = this.$steps.map(el => el.id); + const availableCompleted = completedSteps!.filter(name => stepIds.includes(name)); + completed = availableCompleted.length; + + if (forceShowPlus && availableCompleted.includes('plus')) { + completed -= 1; + } } - $headerContent.setAttribute('steps', steps?.toString() ?? ''); - $headerContent.setAttribute('completed', completed?.toString() ?? ''); + + $headerContent.setAttribute('steps', steps.toString()); + $headerContent.setAttribute('completed', completed.toString()); $headerContent.setAttribute('state', subscription.state.toString()); $headerContent.setAttribute('plan', subscription.plan.effective.name); $headerContent.setAttribute('days', days.toString());