Fix script graph parallel (#12545)

This commit is contained in:
Bram Kragten 2022-05-02 23:47:43 +02:00 committed by GitHub
parent f0c7232704
commit e99143139e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import {
DeviceAction, DeviceAction,
EventAction, EventAction,
IfAction, IfAction,
ManualScriptConfig,
ParallelAction, ParallelAction,
RepeatAction, RepeatAction,
SceneAction, SceneAction,
@ -478,7 +479,20 @@ export class HatScriptGraph extends LitElement {
nofocus nofocus
></hat-graph-node> ></hat-graph-node>
${ensureArray(node.parallel).map((action, i) => ${ensureArray(node.parallel).map((action, i) =>
this.render_action_node(action, `${path}/parallel/${i}/0`) "sequence" in action
? html`<div ?track=${path in this.trace.trace}>
${ensureArray((action as ManualScriptConfig).sequence).map(
(sAction, j) =>
this.render_action_node(
sAction,
`${path}/parallel/${i}/sequence/${j}`
)
)}
</div>`
: this.render_action_node(
action,
`${path}/parallel/${i}/sequence/0`
)
)} )}
</hat-graph-branch> </hat-graph-branch>
`; `;

View File

@ -214,7 +214,7 @@ export interface StopAction extends BaseAction {
} }
export interface ParallelAction extends BaseAction { export interface ParallelAction extends BaseAction {
parallel: Action | Action[]; parallel: ManualScriptConfig | Action | (ManualScriptConfig | Action)[];
} }
interface UnknownAction extends BaseAction { interface UnknownAction extends BaseAction {

View File

@ -185,7 +185,11 @@ export const getDataFromPath = (
const asNumber = Number(raw); const asNumber = Number(raw);
if (isNaN(asNumber)) { if (isNaN(asNumber)) {
result = result[raw]; const tempResult = result[raw];
if (!tempResult && raw === "sequence") {
continue;
}
result = tempResult;
continue; continue;
} }