Skip to content

Commit

Permalink
feat: add else block to 'logic: if' action
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 24, 2025
1 parent 84d3665 commit a7b597f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions companion/lib/Internal/BuildingBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ export class InternalBuildingBlocks implements InternalModuleFragment {
label: 'Then',
entityTypeLabel: 'action',
},
{
type: EntityModelType.Action,
groupId: 'else_actions',
label: 'Else',
entityTypeLabel: 'action',
},
],
},
}
Expand Down Expand Up @@ -284,15 +290,11 @@ export class InternalBuildingBlocks implements InternalModuleFragment {
if (extras.abortDelayed.aborted) return true

const conditionValues = action.getChildren('condition')?.getChildBooleanFeedbackValues() ?? []
if (!booleanAnd(false, conditionValues)) {
// Condition failed, abort
return true
}

const executeGroup = booleanAnd(false, conditionValues) ? 'actions' : 'else_actions'
const childActions = action.getChildren(executeGroup)?.getDirectEntities() ?? []
const executeSequential = extras.executionMode === 'sequential'

const childActions = action.getChildren('actions')?.getDirectEntities() ?? []

return this.#actionRunner
.runMultipleActions(childActions, extras, executeSequential)
.catch((e) => {
Expand Down

0 comments on commit a7b597f

Please sign in to comment.