@@ -26,6 +26,19 @@ function hasProperty (obj, prop) {
2626 return Object . prototype . hasOwnProperty . call ( obj , prop )
2727}
2828
29+ /**
30+ * Test whether a message has any properties other than ui_update, class, visible, enabled and _msgid
31+ * Properties with the value undefined are ignored
32+ * @param {* } msg
33+ * @returns true if other properties found
34+ */
35+ function hasExtraProps ( message ) {
36+ const allowed = [ '_msgid' , 'ui_update' , 'class' , 'visible' , 'enabled' ]
37+ const keys = Object . keys ( message ) . filter ( key => message [ key ] !== undefined )
38+
39+ return keys . length > 0 && keys . some ( key => ! allowed . includes ( key ) )
40+ }
41+
2942module . exports = function ( RED ) {
3043 const express = require ( 'express' )
3144 const { Server } = require ( 'socket.io' )
@@ -1101,8 +1114,11 @@ module.exports = function (RED) {
11011114 msg = await appendTopic ( RED , widgetConfig , wNode , msg )
11021115 }
11031116
1104- // store the latest msg passed to node
1105- datastore . save ( n , widgetNode , msg )
1117+ // store the latest msg passed to the node unless the message only contains
1118+ // ui_update, visible, enabled or class properties, which are handled in the state store
1119+ if ( hasExtraProps ( msg ) ) {
1120+ datastore . save ( n , widgetNode , msg )
1121+ }
11061122
11071123 if ( hasProperty ( widgetConfig , 'passthru' ) ) {
11081124 if ( widgetConfig . passthru ) {
0 commit comments