-
Notifications
You must be signed in to change notification settings - Fork 74
1892 - Don't save message in datastore if payload is missing #1937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1101,8 +1101,10 @@ module.exports = function (RED) { | |
| msg = await appendTopic(RED, widgetConfig, wNode, msg) | ||
| } | ||
|
|
||
| // store the latest msg passed to node | ||
| datastore.save(n, widgetNode, msg) | ||
| // store the latest msg passed to node unless payload is missing | ||
| if (typeof msg.payload !== 'undefined') { | ||
| datastore.save(n, widgetNode, msg) | ||
| } | ||
|
Comment on lines
+1105
to
+1107
|
||
|
|
||
| if (hasProperty(widgetConfig, 'passthru')) { | ||
| if (widgetConfig.passthru) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change creates an inconsistency with widgets that have custom
onInputhandlers. For example,ui_switch.js(lines 58-60) explicitly saves to datastore whenmsg.payload === undefinedwith the comment "may be setting class dynamically or something else that doesn't require a payload". Since the purpose of this fix is to prevent saving messages without payloads (to avoid clearing displays on refresh), consider whether widgets with customonInputhandlers likeui_switchshould also skip saving when payload is undefined for consistency.