mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
WifiUi: sort networks on show event (#37390)
* should fail * this works but i think i know a better way * something like this * hmm * this works * rm useless test * good stash * Revert "good stash" This reverts commit c2dddf0810286cb56e2418dd6f7085c2239e5109.
This commit is contained in:
@@ -298,7 +298,8 @@ class WifiUIMici(NavWidget):
|
||||
self._loading_animation.show_event()
|
||||
self._wifi_manager.set_active(True)
|
||||
self._scroller.items.clear()
|
||||
self._update_buttons()
|
||||
# trigger button update on latest sorted networks
|
||||
self._on_network_updated(self._wifi_manager.networks)
|
||||
|
||||
def hide_event(self):
|
||||
super().hide_event()
|
||||
|
||||
@@ -154,7 +154,7 @@ class WifiState:
|
||||
|
||||
class WifiManager:
|
||||
def __init__(self):
|
||||
self._networks: list[Network] = [] # a network can be comprised of multiple APs
|
||||
self._networks: list[Network] = [] # an unsorted list of available Networks. a Network can be comprised of multiple APs
|
||||
self._active = True # used to not run when not in settings
|
||||
self._exit = False
|
||||
|
||||
@@ -264,7 +264,8 @@ class WifiManager:
|
||||
|
||||
@property
|
||||
def networks(self) -> list[Network]:
|
||||
return self._networks
|
||||
# Sort by connected/connecting, then known, then strength, then alphabetically. This is a pure UI ordering and should not affect underlying state.
|
||||
return sorted(self._networks, key=lambda n: (n.ssid != self._wifi_state.ssid, not self.is_connection_saved(n.ssid), -n.strength, n.ssid.lower()))
|
||||
|
||||
@property
|
||||
def wifi_state(self) -> WifiState:
|
||||
@@ -826,13 +827,9 @@ class WifiManager:
|
||||
# catch all for parsing errors
|
||||
cloudlog.exception(f"Failed to parse AP properties for {ap_path}")
|
||||
|
||||
networks = [Network.from_dbus(ssid, ap_list, ssid == self._tethering_ssid) for ssid, ap_list in aps.items()]
|
||||
networks.sort(key=lambda n: (n.ssid != self._wifi_state.ssid, not self.is_connection_saved(n.ssid), -n.strength, n.ssid.lower()))
|
||||
self._networks = networks
|
||||
|
||||
self._networks = [Network.from_dbus(ssid, ap_list, ssid == self._tethering_ssid) for ssid, ap_list in aps.items()]
|
||||
self._update_active_connection_info()
|
||||
|
||||
self._enqueue_callbacks(self._networks_updated, self._networks)
|
||||
self._enqueue_callbacks(self._networks_updated, self.networks) # sorted
|
||||
|
||||
if block:
|
||||
worker()
|
||||
|
||||
Reference in New Issue
Block a user