only keep strongest network by ssid

(cherry picked from commit 9f0a19e2655637313ac4673b83e6803a30f5c546)
This commit is contained in:
Leon Camus
2024-05-17 15:10:28 +02:00
parent ca135fc4f7
commit a170dd42c6
@@ -167,7 +167,16 @@ export default (props) => {
child: Box({
attribute: {
'updateNetworks': (self) => {
self.children = Network.wifi?.access_points?.map(n => WifiNetwork(n));
const accessPoints = Network.wifi?.access_points || [];
self.children = Object.values(accessPoints.reduce((a, accessPoint) => {
// Only keep max strength networks by ssid
if (!a[accessPoint.ssid] || a[accessPoint.ssid].strength < accessPoint.strength) {
a[accessPoint.ssid] = accessPoint;
a[accessPoint.ssid].active |= accessPoint.active;
}
return a;
}, {})).map(n => WifiNetwork(n));
},
},
vertical: true,