Sort VPN connections alphabetically
Adds case-insensitive alphabetical sorting to the VPN connections list. The connections are now sorted by name when received and before display, making it easier to find specific VPN profiles. Fixes #1947
This commit is contained in:
parent
703a934b09
commit
f2c374ff6b
1 changed files with 27 additions and 2 deletions
|
|
@ -428,7 +428,19 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::KnownConnections(connections) => {
|
Message::KnownConnections(connections) => {
|
||||||
self.known_connections = connections;
|
let mut connections: Vec<_> = connections.into_iter().collect();
|
||||||
|
connections.sort_by(|a, b| {
|
||||||
|
let name_a = match &a.1 {
|
||||||
|
ConnectionSettings::Vpn(s) => s.id.as_str(),
|
||||||
|
ConnectionSettings::Wireguard { id } => id.as_str(),
|
||||||
|
};
|
||||||
|
let name_b = match &b.1 {
|
||||||
|
ConnectionSettings::Vpn(s) => s.id.as_str(),
|
||||||
|
ConnectionSettings::Wireguard { id } => id.as_str(),
|
||||||
|
};
|
||||||
|
name_a.to_lowercase().cmp(&name_b.to_lowercase())
|
||||||
|
});
|
||||||
|
self.known_connections = connections.into_iter().collect();
|
||||||
}
|
}
|
||||||
Message::UpdateDevices(devices) => {
|
Message::UpdateDevices(devices) => {
|
||||||
self.update_devices(devices);
|
self.update_devices(devices);
|
||||||
|
|
@ -1005,7 +1017,20 @@ fn devices_view() -> Section<crate::pages::Message> {
|
||||||
widget::text::body(fl!("no-vpn")).into(),
|
widget::text::body(fl!("no-vpn")).into(),
|
||||||
])));
|
])));
|
||||||
} else {
|
} else {
|
||||||
let known_networks = page.known_connections.iter().fold(
|
let mut known_connections: Vec<_> = page.known_connections.iter().collect();
|
||||||
|
known_connections.sort_by(|a, b| {
|
||||||
|
let name_a = match a.1 {
|
||||||
|
ConnectionSettings::Vpn(s) => s.id.as_str(),
|
||||||
|
ConnectionSettings::Wireguard { id } => id.as_str(),
|
||||||
|
};
|
||||||
|
let name_b = match b.1 {
|
||||||
|
ConnectionSettings::Vpn(s) => s.id.as_str(),
|
||||||
|
ConnectionSettings::Wireguard { id } => id.as_str(),
|
||||||
|
};
|
||||||
|
name_a.to_lowercase().cmp(&name_b.to_lowercase())
|
||||||
|
});
|
||||||
|
|
||||||
|
let known_networks = known_connections.into_iter().fold(
|
||||||
vpn_connections,
|
vpn_connections,
|
||||||
|networks, (uuid, connection)| {
|
|networks, (uuid, connection)| {
|
||||||
let id = match connection {
|
let id = match connection {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue