Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unsolicited resend of last msg to ui-template node #822

Open
omrid01 opened this issue Nov 7, 2023 · 1 comment
Open

Unsolicited resend of last msg to ui-template node #822

omrid01 opened this issue Nov 7, 2023 · 1 comment

Comments

@omrid01
Copy link

omrid01 commented Nov 7, 2023

Current Behavior

I'm receiving messages in dashboard ui-template nodes as follows:

<script type="text/javascript">
var $scope = this.scope;
(function(scope) {
    $scope.$watch('msg', function(msg)
    {
        if (msg)
            console.log(`Incoming msg: payload=${msg.payload||"None"}`);
            // Process the msg
    });
})(scope);
</script>

When I load the page (dashboard tab) directly (using .../ui/#!/<n>), everything works OK. However, if I move to this page from another dashboard tab (using the dashboard's hamburger menu), the last received msg is automatically sent again into the template node.
Am I doing something wrong?

Expected Behavior

No response

Steps To Reproduce

Consider the following flow:
image

I injected a timestamp to the template node, then moved to another tab and came back. The previous timestamp message was resent automatically:
image
Note that I have unchecked the "Reload last value on refresh" in the template node

Example flow

[
    {
        "id": "e49fb0bed113e1f8",
        "type": "tab",
        "label": "Test-init",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e2df5e12686bbd49",
        "type": "ui_template",
        "z": "e49fb0bed113e1f8",
        "group": "9d67e041ac5c0883",
        "name": "UI Form",
        "order": 2,
        "width": "5",
        "height": "2",
        "format": "<form>\n  <h1>Test Page Load</h1>\n</form>\n\n<script type=\"text/javascript\">\nvar $scope = this.scope;\n(function(scope) {\n    $scope.$watch('msg', function(msg)\n    {\n        if (msg)\n            console.log(`Incoming msg: payload=${msg.payload||\"None\"}`);\n    });\n})(scope);\n</script>\n",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 280,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "f89bd99daeeda980",
        "type": "inject",
        "z": "e49fb0bed113e1f8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 160,
        "wires": [
            [
                "e2df5e12686bbd49"
            ]
        ]
    },
    {
        "id": "9d67e041ac5c0883",
        "type": "ui_group",
        "name": "Group 1",
        "tab": "2a958acb350ce105",
        "order": 1,
        "disp": true,
        "width": 6
    },
    {
        "id": "2a958acb350ce105",
        "type": "ui_tab",
        "name": "Test-Init",
        "icon": "dashboard",
        "order": 17,
        "disabled": false,
        "hidden": false
    }
]

Environment

  • Node-RED version: 3.1
  • Node.js version: 18, 21
  • npm version: 9, 10
  • Platform/OS: Windows
  • Browser: Edge, Chrome
@knolleary
Copy link
Member

Hi - this repository is for the core of Node-RED. As this appears to be a node-red-dashboard related issue/question, I'm going to transfer the issue over to that repo.

@knolleary knolleary transferred this issue from node-red/node-red Nov 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants