@andreydk1981/node-red-dashboard-2-ui-projector 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,14 @@ module.exports = function (RED) {
14
14
  onAction: function (msg, send, done) {
15
15
  // get current name
16
16
  const currentName = node.context().get('name') || config.name || 'projector'
17
- // set topic to current name
18
- msg.topic = currentName
19
- send(msg)
17
+ // only forward explicit button actions (ON/OFF)
18
+ if (msg && (msg.payload === 'ON' || msg.payload === 'OFF')) {
19
+ msg.topic = currentName
20
+ send(msg)
21
+ }
22
+ if (done) {
23
+ done()
24
+ }
20
25
  },
21
26
 
22
27
  beforeSend: function (msg) {
@@ -28,20 +33,21 @@ module.exports = function (RED) {
28
33
  return msg
29
34
  },
30
35
  onInput: function (msg, send, done) {
31
- // handle name change
36
+ // handle name change (persist but do not forward)
32
37
  if (msg.name) {
33
38
  node.context().set('name', msg.name)
34
39
  }
35
- // determine current name
36
- const currentName = node.context().get('name') || config.name || 'projector'
37
- // for action messages from widget (ON/OFF) set topic to current name
38
- if (msg.payload === 'ON' || msg.payload === 'OFF') {
40
+ // store the latest value for the UI
41
+ base.stores.data.save(base, node, msg)
42
+ // only forward when user presses ON/OFF buttons
43
+ if (msg && (msg.payload === 'ON' || msg.payload === 'OFF')) {
44
+ const currentName = node.context().get('name') || config.name || 'projector'
39
45
  msg.topic = currentName
46
+ send(msg)
47
+ }
48
+ if (done) {
49
+ done()
40
50
  }
41
- // store the latest value
42
- base.stores.data.save(base, node, msg)
43
- // send to connected nodes
44
- send(msg)
45
51
  }
46
52
  }
47
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreydk1981/node-red-dashboard-2-ui-projector",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },