Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions app/blocks/logic/current_trigger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

/** @type {import('#types').BlockDefinitionRaw} */
export default {
type: "current_trigger",
name: "Trigger Compare",
bytecodeKey: "current_trigger",
colour: 60,
description: "Returns a boolean expression indicating whether the Action was triggered by the same trigger as this block.",

connections: {
mode: "value",
output: "expression",
},

template: "Current Trigger: %INPUT_A",

inputs: {
INPUT_A: {
description: "The trigger block to compare with the Actions triggers, returning true if the action was triggered by the same trigger.",
check: "trigger",
type: "statement",
shadow: {
type: 'when_data',
fields: { FEED_KEY: "" }
}
}
},

generators: {
json: (block, generator) => {
const payload = {
current_trigger: {
trigger: JSON.parse(generator.statementToCode(block, 'INPUT_A') || null)
}
}

return JSON.stringify(payload)
}
},

regenerators: {
json: (blockObject, helpers) => {
const payload = blockObject.current_trigger
return {
type: 'current_trigger',
inputs: {
INPUT_A: helpers.expressionToBlock(payload.trigger, { shadow: 'when_data' })
}
}
}
}
}
1 change: 1 addition & 0 deletions app/toolbox/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
"io_logic_negate",
"io_logic_compare",
"text_compare",
"current_trigger"
]
}