Add scrollable nearby networks section and prevent concurrent updates

This commit is contained in:
Jalil Arfaoui 2026-02-27 00:03:00 +01:00
parent 41dd546394
commit d0ad901aab
2 changed files with 29 additions and 5 deletions

View file

@ -115,7 +115,9 @@ export default class WifiSignalPlusExtension extends Extension {
private headerBandLabel: St.Label | null = null; private headerBandLabel: St.Label | null = null;
private headerIcon: St.Icon | null = null; private headerIcon: St.Icon | null = null;
private nearbySeparator: PopupMenu.PopupSeparatorMenuItem | null = null; private nearbySeparator: PopupMenu.PopupSeparatorMenuItem | null = null;
private nearbySection: PopupMenu.PopupMenuSection | null = null;
private nearbyItems: NearbyNetworkCard[] = []; private nearbyItems: NearbyNetworkCard[] = [];
private nearbyUpdatePending = false;
private currentConnectedBssid: string | undefined; private currentConnectedBssid: string | undefined;
private isMenuOpen = false; private isMenuOpen = false;
@ -160,7 +162,9 @@ export default class WifiSignalPlusExtension extends Extension {
this.headerBandLabel = null; this.headerBandLabel = null;
this.headerIcon = null; this.headerIcon = null;
this.nearbySeparator = null; this.nearbySeparator = null;
this.nearbySection = null;
this.nearbyItems = []; this.nearbyItems = [];
this.nearbyUpdatePending = false;
this.currentConnectedBssid = undefined; this.currentConnectedBssid = undefined;
this.isMenuOpen = false; this.isMenuOpen = false;
} }
@ -225,6 +229,16 @@ export default class WifiSignalPlusExtension extends Extension {
this.nearbySeparator = new PopupMenu.PopupSeparatorMenuItem('Nearby Networks'); this.nearbySeparator = new PopupMenu.PopupSeparatorMenuItem('Nearby Networks');
menu.addMenuItem(this.nearbySeparator); 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 { private addConnectionHeader(menu: PopupMenu.PopupMenu): void {
@ -581,7 +595,15 @@ export default class WifiSignalPlusExtension extends Extension {
} }
private async updateNearbyNetworks(): Promise<void> { private async updateNearbyNetworks(): Promise<void> {
if (!this.wifiService || !this.indicator) return; if (!this.wifiService || !this.nearbySection || this.nearbyUpdatePending) return;
this.nearbyUpdatePending = true;
let grouped: Map<string, ScannedNetwork[]>;
try {
grouped = await this.wifiService.getAvailableNetworks(this.currentConnectedBssid);
} finally {
this.nearbyUpdatePending = false;
}
const expandedSsids = new Set( const expandedSsids = new Set(
this.nearbyItems this.nearbyItems
@ -589,14 +611,11 @@ export default class WifiSignalPlusExtension extends Extension {
.map(card => card._ssid), .map(card => card._ssid),
); );
const menu = this.indicator.menu as PopupMenu.PopupMenu;
this.clearNearbyItems(); this.clearNearbyItems();
const grouped = await this.wifiService.getAvailableNetworks(this.currentConnectedBssid);
for (const [ssid, networks] of grouped) { for (const [ssid, networks] of grouped) {
const card = this.createNetworkCard(ssid, networks[0], networks); const card = this.createNetworkCard(ssid, networks[0], networks);
menu.addMenuItem(card); this.nearbySection.addMenuItem(card);
this.nearbyItems.push(card); this.nearbyItems.push(card);
if (expandedSsids.has(ssid)) { if (expandedSsids.has(ssid)) {

View file

@ -143,6 +143,11 @@
color: #e01b24; color: #e01b24;
} }
/* Nearby networks - Scroll container */
.wifi-nearby-scroll {
max-height: 250px;
}
/* Nearby networks - Card header */ /* Nearby networks - Card header */
.wifi-nearby-card { .wifi-nearby-card {
margin: 2px 0; margin: 2px 0;