feat(src/window): migrate device monitoring to map/unmap events

Ensure monitoring starts only when the widget is shown and stops on hide, preventing timer leaks and unnecessary refreshes
This commit is contained in:
sankalp committed 2026-06-23 14:11:25 +05:45
1 parent 01fed4c52f
commit 6707e1e830
8 files changed
+95 -29

No files matched your search

+2 -2
View File
@@ -421,13 +421,12 @@ class BluetoothConnections(Box):
self.connect("destroy", self.on_destroy)
self.connect("unmap", self.on_hide)
self.connect("map", lambda *_: self.start_device_monitoring())
self.client.notify("scanning")
self.client.notify("enabled")
self.update_devices()
self.start_device_monitoring()
def handle_user_toggle(self, active: bool):
self._switch_lock = True
set_bluetooth_enabled_with_fallback(self.client, active)
@@ -441,6 +440,7 @@ class BluetoothConnections(Box):
def on_hide(self, *_):
"""Called when the widget is hidden (popup closed)"""
self.stop_device_monitoring()
if self.other_devices.get_visible():
self.other_devices.set_visible(False)
self.other_devices_scrolled.snap_to_size(0)