Skip to content

Commit

Permalink
fix: children child_id issue from multiple commands changes
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticrake committed May 26, 2020
1 parent b94c6d4 commit 1374011
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"ssid",
"subnet",
"truthy",
"unencrypted",
"wifi",

"SNDBUF",
Expand Down
33 changes: 19 additions & 14 deletions src/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,26 @@ class Device {
}

processUdpMessage(msg) {
return this.processMessage(msg, encrypt, (obj) => {
// UDP only returns last two characters of child.id
if (
obj.system &&
obj.system.get_sysinfo &&
obj.system.get_sysinfo.children &&
obj.system.get_sysinfo.children.length > 0
) {
obj.system.get_sysinfo.children.forEach((child) => {
// eslint-disable-next-line no-param-reassign
child.id = child.id.slice(-2);
});
return this.processMessage(
msg,
encrypt,
(moduleName, methodName, methodResponse) => {
// UDP only returns last two characters of child.id
if (
moduleName === 'system' &&
methodName === 'get_sysinfo' &&
methodResponse &&
methodResponse.children &&
methodResponse.children.length > 0
) {
methodResponse.children.forEach((child) => {
// eslint-disable-next-line no-param-reassign
child.id = child.id.slice(-2);
});
}
return methodResponse;
}
return obj;
});
);
}

processTcpMessage(msg) {
Expand Down

0 comments on commit 1374011

Please sign in to comment.