Skip to content

Commit

Permalink
Fixes uniqueTagManagers() when the set of tags for a UUID is empty
Browse files Browse the repository at this point in the history
Fixes #23.
  • Loading branch information
hlapp committed Feb 14, 2017
1 parent d752c5c commit 20af98d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/polling-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,14 @@ PollingTagUpdater.prototype.apiClient = function() {
* @returns {WirelessTagManager[]}
*/
PollingTagUpdater.prototype.uniqueTagManagers = function() {
let mgrs = Object.keys(this.tagsByUUID).map((uuid) => {
let mgrByMAC = new Map();
Object.keys(this.tagsByUUID).forEach((uuid) => {
let tags = Array.from(this.tagsByUUID[uuid]);
return tags.length > 0 ? tags[0].wirelessTagManager : undefined;
if (tags.length > 0) {
let mgr = tags[0].wirelessTagManager;
mgrByMAC.set(mgr.mac, mgr);
}
});
let mgrByMAC = new Map();
mgrs.forEach( (mgr) => mgrByMAC.set(mgr.mac, mgr) );
return Array.from(mgrByMAC.values());
};

Expand Down

0 comments on commit 20af98d

Please sign in to comment.