From d0ad901aab857ec308740cfee38fd61edda57103 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Fri, 27 Feb 2026 00:03:00 +0100 Subject: [PATCH] Add scrollable nearby networks section and prevent concurrent updates --- src/extension.ts | 29 ++++++++++++++++++++++++----- stylesheet.css | 5 +++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 8b886a3..fea62ac 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -115,7 +115,9 @@ export default class WifiSignalPlusExtension extends Extension { private headerBandLabel: St.Label | null = null; private headerIcon: St.Icon | null = null; private nearbySeparator: PopupMenu.PopupSeparatorMenuItem | null = null; + private nearbySection: PopupMenu.PopupMenuSection | null = null; private nearbyItems: NearbyNetworkCard[] = []; + private nearbyUpdatePending = false; private currentConnectedBssid: string | undefined; private isMenuOpen = false; @@ -160,7 +162,9 @@ export default class WifiSignalPlusExtension extends Extension { this.headerBandLabel = null; this.headerIcon = null; this.nearbySeparator = null; + this.nearbySection = null; this.nearbyItems = []; + this.nearbyUpdatePending = false; this.currentConnectedBssid = undefined; this.isMenuOpen = false; } @@ -225,6 +229,16 @@ export default class WifiSignalPlusExtension extends Extension { this.nearbySeparator = new PopupMenu.PopupSeparatorMenuItem('Nearby Networks'); menu.addMenuItem(this.nearbySeparator); + + this.nearbySection = new PopupMenu.PopupMenuSection(); + const scrollView = new St.ScrollView({ + style_class: 'wifi-nearby-scroll', + overlay_scrollbars: true, + }); + scrollView.add_child(this.nearbySection.actor); + const scrollItem = new PopupMenu.PopupBaseMenuItem({ reactive: false }); + scrollItem.add_child(scrollView); + menu.addMenuItem(scrollItem); } private addConnectionHeader(menu: PopupMenu.PopupMenu): void { @@ -581,7 +595,15 @@ export default class WifiSignalPlusExtension extends Extension { } private async updateNearbyNetworks(): Promise { - if (!this.wifiService || !this.indicator) return; + if (!this.wifiService || !this.nearbySection || this.nearbyUpdatePending) return; + + this.nearbyUpdatePending = true; + let grouped: Map; + try { + grouped = await this.wifiService.getAvailableNetworks(this.currentConnectedBssid); + } finally { + this.nearbyUpdatePending = false; + } const expandedSsids = new Set( this.nearbyItems @@ -589,14 +611,11 @@ export default class WifiSignalPlusExtension extends Extension { .map(card => card._ssid), ); - const menu = this.indicator.menu as PopupMenu.PopupMenu; this.clearNearbyItems(); - const grouped = await this.wifiService.getAvailableNetworks(this.currentConnectedBssid); - for (const [ssid, networks] of grouped) { const card = this.createNetworkCard(ssid, networks[0], networks); - menu.addMenuItem(card); + this.nearbySection.addMenuItem(card); this.nearbyItems.push(card); if (expandedSsids.has(ssid)) { diff --git a/stylesheet.css b/stylesheet.css index 3052430..bc124e3 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -143,6 +143,11 @@ color: #e01b24; } +/* Nearby networks - Scroll container */ +.wifi-nearby-scroll { + max-height: 250px; +} + /* Nearby networks - Card header */ .wifi-nearby-card { margin: 2px 0;