Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/api/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ let saved_vpns = snapshot.saved_vpn_map();
let applet = snapshot.applet_summary();
```

`wifi_groups()` groups access points by `(interface, ssid)`, keeps every BSSID,
`wifi_groups()` groups visible access points by `(interface, ssid)`, keeps every BSSID,
marks known networks from matching saved profiles, and marks the active group
from typed active Wi-Fi connections.

Expand Down
25 changes: 21 additions & 4 deletions nmrs/src/api/models/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ impl NetworkSnapshot {
pub fn wifi_groups(&self) -> Vec<WifiNetworkGroup> {
let mut grouped: HashMap<(String, String), Vec<AccessPoint>> = HashMap::new();
for ap in &self.access_points {
grouped
.entry((ap.interface.clone(), ap.ssid.clone()))
.or_default()
.push(ap.clone());
if !ap.ssid.is_empty() {
grouped
.entry((ap.interface.clone(), ap.ssid.clone()))
.or_default()
.push(ap.clone());
}
}

let mut groups = grouped
Expand Down Expand Up @@ -668,4 +670,19 @@ mod tests {
assert_eq!(vpns["active-vpn"].kind, Some(VpnKind::Plugin));
assert_eq!(vpns["wg-vpn"].kind, Some(VpnKind::WireGuard));
}

#[test]
fn hidden_networks_not_shown() {
let snapshot = snapshot(
vec![
ap("wlan0", "", "AA:AA:AA:AA:AA:01", 70),
ap("wlan1", "Cafe", "BB:BB:BB:BB:BB:01", 90),
],
Vec::new(),
Vec::new(),
Vec::new(),
);
let groups = snapshot.wifi_groups();
assert_eq!(groups.len(), 1);
}
}