Skip to content

Commit

Permalink
Merge pull request #466 from FlowFuse/462-ui-control
Browse files Browse the repository at this point in the history
More robust handling of scoped .socket message emissions
  • Loading branch information
joepavitt authored Jan 3, 2024
2 parents 9df002c + 24ec2f1 commit 646ac88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nodes/config/ui_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ module.exports = function (RED) {
*/
function emit (event, msg, wNode) {
Object.values(uiShared.connections).forEach(conn => {
const nodeAllowsConstraints = n.acceptsClientConfig?.includes(wNode.type)
const nodeAllowsConstraints = wNode ? n.acceptsClientConfig?.includes(wNode.type) : true
if ((nodeAllowsConstraints && isValidConnection(conn, msg)) || !nodeAllowsConstraints) {
conn.emit(event, msg)
}
Expand Down Expand Up @@ -314,7 +314,7 @@ module.exports = function (RED) {
checks.push(msg._client?.socketId === conn.id)
}
// if ANY check says this is valid - we send the msg
return checks.includes(true)
return !checks.length || checks.includes(true)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion nodes/widgets/ui_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (RED) {
}

function emit (payload) {
ui.emit('ui-control:' + node.id, payload)
ui.emit('ui-control:' + node.id, payload, node)
}

const evts = {
Expand Down

0 comments on commit 646ac88

Please sign in to comment.