Skip to content
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

Bug: Improper handling of 'layer' #292

Closed
phreed opened this issue Oct 15, 2024 · 2 comments
Closed

Bug: Improper handling of 'layer' #292

phreed opened this issue Oct 15, 2024 · 2 comments

Comments

@phreed
Copy link

phreed commented Oct 15, 2024

In node-red-contrib-web-worldmap/worldmap.js :

RedMap/worldmap.js

Lines 354 to 356 in 7d1782c

if ((node.events.indexOf("layer")!==-1) && (message.action.indexOf("layer") !== -1) ) {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
}

This gives me an error: TypeError: Cannot read properties of null (reading 'indexOf')
The following change stopped the error.

   if ((node.events.indexOf("layer")!==-1) && (message.action === "layer") )  {
       setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
   }

Does 'message.action.indexOf(...)' make sense?

@zafrirron
Copy link
Contributor

zafrirron commented Oct 22, 2024

Can you give some more details about this error, how can I reproduce it?
the reason for the message.action.indexOf("layer") is to capture addlayer and dellayer actions to be send back to backend

@phreed
Copy link
Author

phreed commented Oct 22, 2024

I can try to reproduce the error. It happened on initial load, possibly following the introduction of https://github.com/FreeTAKTeam/FreeTAKHub-Webmap/blob/main/freetakhub_webmap_v5.json by https://github.com/FreeTAKTeam/FreeTAKHub-Installation/tree/120-update-nodered-to-31.

I suspect it is related to the introduction of the following menu:

    {
        "id": "70c9a88a608c375e",
        "type": "function",
        "z": "2c12da721d40c6cc",
        "name": "Add The Menu",
        "func": "msg.payload = { \n  command: {\ncontextmenu: String.raw`\n<table border=0><tr>\n<th>Attitude</th><td><select id=\"myatt\">\n  <option value=\"friend\">Friend</option>\n  <option value=\"hostile\">Hostile</option>\n  <option value=\"neutral\">Neutral</option>\n  <option value=\"unknown\">Unknown</option>\n  <option value=\"pending\">Pending</option>\n  <option value=\"suspect\">Suspect</option>\n  <option value=\"assumed\">Assumed Friend</option>\n  </select></td>\n</tr><tr>\n<th>Type</th><td><select id=\"mytyp\" value=\"Ground\" onchange=\"document.getElementById('mynam').value = this.value+'-'+parseInt(Math.random()*9999);\">\n  <option value=\"Ground\">Ground</option>\n  <option value=\"Gnd Equip Vehicle\">Gnd Equip Vehicle</option>\n  <option value=\"Gnd Combat Infantry Rifleman\">Rifleman</option>\n  <option value=\"Gnd Combat Infantry grenadier\">Grenadier</option>\n  <option value=\"Gnd Combat Infantry Mortar\">Mortar</option>\n  <option value=\"Gnd Combat Infantry MachineGunner (LMG)\">LMG</option>\n  <option value=\"Gnd Combat Infantry Medic\">Medic</option>\n  <option value=\"Gnd Combat Infantry anti Tank\">anti Tank</option>\n  <option value=\"Gnd Combat Infantry Sniper\">Sniper</option>\n  <option value=\"Gnd Combat Infantry Recon\">Recon</option>\n  <option value=\"Gnd Combat Infantry air defense\">AA</option>\n  <option value=\"Gnd Combat Infantry Engineer\">Engineer</option>\n</select></td>\n</tr><tr>\n<th>Timeout</th>\n<td><input type=\"number\" id=\"mytout\" step=\"10\" value=\"600\">S</td>\n</tr><tr>\n<th>Name</th><td><input type=\"text\" id=\"mynam\"></td>\n</tr><tr>\n<th>\n  <input name=\"my_spot_report\"\n    type=\"button\" value=\"Send\"\n    onclick=\n'feedback(\"map\", {\n    \"attitude\":document.getElementById(\"myatt\").value,\n    \"geoObject\":document.getElementById(\"mytyp\").value,\n    \"timeout\":document.getElementById(\"mytout\").value,\n    \"name\":document.getElementById(\"mynam\").value,\n    \"bearing\": 0.0,\n    \"distance\": 1.0,\n    \"how\": \"nonCoT\",\n},\"feedback\",true)'\n></th>\n</tr></table>\n`\n}\n}\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 540,
        "y": 340,
        "wires": [
            [
                "68d5546bc74741de"
            ]
        ]
    },

However, I have not verified that this is the cause.
I should be able to get back to it next week.

@dceejay dceejay closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants