quickshell: fix network list flicker during refresh
Accumulate scan results into a temp array, swap to wifiNetworks in one assignment when the process finishes. No more clearing the list before each scan. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
917d983861
commit
8fe48557e4
1 changed files with 11 additions and 6 deletions
|
|
@ -641,6 +641,8 @@ in
|
|||
onTriggered: netWidget.refreshNet()
|
||||
}
|
||||
|
||||
property var _pendingNets: []
|
||||
|
||||
Process {
|
||||
id: wifiScanProc
|
||||
command: ["${pkgs.networkmanager}/bin/nmcli", "-t", "-f", "SSID,SIGNAL,SECURITY,IN-USE", "device", "wifi", "list", "--rescan", "auto"]
|
||||
|
|
@ -648,17 +650,21 @@ in
|
|||
onRead: data => {
|
||||
let fields = data.split(":");
|
||||
if (fields.length < 4 || fields[0] === "") return;
|
||||
let nets = netWidget.wifiNetworks.slice();
|
||||
for (let i = 0; i < nets.length; i++) {
|
||||
if (nets[i].ssid === fields[0]) return;
|
||||
for (let i = 0; i < netWidget._pendingNets.length; i++) {
|
||||
if (netWidget._pendingNets[i].ssid === fields[0]) return;
|
||||
}
|
||||
nets.push({
|
||||
netWidget._pendingNets.push({
|
||||
ssid: fields[0],
|
||||
signal: parseInt(fields[1]) || 0,
|
||||
security: fields[2],
|
||||
active: fields[3] === "*"
|
||||
});
|
||||
netWidget.wifiNetworks = nets;
|
||||
}
|
||||
}
|
||||
onRunningChanged: {
|
||||
if (!running) {
|
||||
netWidget.wifiNetworks = netWidget._pendingNets;
|
||||
netWidget._pendingNets = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -683,7 +689,6 @@ in
|
|||
|
||||
function openNetDropdown() {
|
||||
bar.toggleDropdown(netDropdown, function() {
|
||||
netWidget.wifiNetworks = [];
|
||||
wifiScanProc.running = true;
|
||||
let pos = netWidget.mapToItem(bar.contentItem, netWidget.width / 2, 0);
|
||||
netDropdown.dropdownX = pos.x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue