From 3a305a44b6f6e5a2cf58d16f9bfde97192b2e884 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 2 May 2022 23:48:28 +0200 Subject: [PATCH] Handle if in repeat (#12544) --- src/components/trace/hat-script-graph.ts | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index b43dd2749e..cab2f87c33 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -215,7 +215,19 @@ export class HatScriptGraph extends LitElement { private render_if_node(config: IfAction, path: string, graphStart = false) { const trace = this.trace.trace[path] as IfActionTraceStep[] | undefined; - const result = trace?.[0].result?.choice; + let trackThen = false; + let trackElse = false; + for (const trc of trace || []) { + if (!trackThen && trc.result?.choice === "then") { + trackThen = true; + } + if ((!trackElse && trc.result?.choice === "else") || !trc.result) { + trackElse = true; + } + if (trackElse && trackThen) { + break; + } + } return html` ${config.else - ? html`
+ ? html`
` - : html``} -
+ : html``} +