From 44f1103259802dce4e9aa5f1add18799d789e47a Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 18 Jul 2026 21:43:29 +0545 Subject: [PATCH] refactor(per_app_volume): remove redundant 2s polling - stream-added/stream-removed signals already handle app list updates - Removed _auto_refresh(), _on_map/_on_unmap timer management - Removed _last_app_names tracking (unused without polling) --- src/window/controlcenter/per_app_volume.py | 38 ---------------------- 1 file changed, 38 deletions(-) diff --git a/src/window/controlcenter/per_app_volume.py b/src/window/controlcenter/per_app_volume.py index 0ebcbb3..b03d8ad 100644 --- a/src/window/controlcenter/per_app_volume.py +++ b/src/window/controlcenter/per_app_volume.py @@ -65,7 +65,6 @@ class PerAppVolumeControl(Box): self._app_widgets = {} self._signal_connections = [] self._destroyed = False - self._refresh_timer = None # Header with back button self.header = Box( @@ -112,38 +111,9 @@ class PerAppVolumeControl(Box): audio_service.connect("stream-removed", self._on_stream_changed) ) - # Track last known app names to avoid unnecessary rebuilds - self._last_app_names = frozenset() - # Initial population self._populate_apps() - self.connect("map", self._on_map) - self.connect("unmap", self._on_unmap) - - def _auto_refresh(self): - """Auto-refresh the application list every 2 seconds""" - if self._destroyed: - self._refresh_timer = None - return False - if not audio_service: - return True - apps = audio_service.applications or [] - current_names = frozenset(a.name or "" for a in apps) - if current_names != self._last_app_names: - self._last_app_names = current_names - self._populate_apps() - return True - - def _on_map(self, *_): - if self._refresh_timer is None: - self._refresh_timer = GLib.timeout_add_seconds(2, self._auto_refresh) - - def _on_unmap(self, *_): - if self._refresh_timer is not None: - GLib.source_remove(self._refresh_timer) - self._refresh_timer = None - def _go_back(self, *_): """Return to main control center view""" self.control_center.close_per_app_volume() @@ -354,14 +324,6 @@ class PerAppVolumeControl(Box): """Clean up resources""" self._destroyed = True - # Stop the auto-refresh timer - if self._refresh_timer is not None: - try: - GLib.source_remove(self._refresh_timer) - except Exception as e: - logger.error(f"An error occurred: {e}") - self._refresh_timer = None - # Disconnect audio service signals if audio_service: for connection in self._signal_connections: