controlcenter: fix bug, connection information update event

This commit is contained in:
ATMDA 2025-11-14 13:55:12 -05:00
parent c30022b75e
commit f39c4b6e6c

View file

@ -23,6 +23,11 @@ Item {
} }
onNetworkChanged: { onNetworkChanged: {
// Restart timer when network changes
connectionUpdateTimer.stop();
if (network && network.ssid) {
connectionUpdateTimer.start();
}
updateDeviceDetails(); updateDeviceDetails();
checkSavedProfile(); checkSavedProfile();
} }
@ -38,11 +43,56 @@ Item {
function onActiveChanged() { function onActiveChanged() {
updateDeviceDetails(); updateDeviceDetails();
} }
function onWirelessDeviceDetailsChanged() {
// When details are updated, check if we should stop the timer
if (network && network.ssid) {
const isActive = network.active || (Nmcli.active && Nmcli.active.ssid === network.ssid);
if (isActive && Nmcli.wirelessDeviceDetails && Nmcli.wirelessDeviceDetails !== null) {
// We have details for the active network, stop the timer
connectionUpdateTimer.stop();
}
}
}
}
Timer {
id: connectionUpdateTimer
interval: 500
repeat: true
running: network && network.ssid
onTriggered: {
// Periodically check if network becomes active and update details
if (network) {
const isActive = network.active || (Nmcli.active && Nmcli.active.ssid === network.ssid);
if (isActive) {
// Network is active - check if we have details
if (!Nmcli.wirelessDeviceDetails || Nmcli.wirelessDeviceDetails === null) {
// Network is active but we don't have details yet, fetch them
Nmcli.getWirelessDeviceDetails("", () => {
// After fetching, check if we got details - if not, timer will try again
});
} else {
// We have details, can stop the timer
connectionUpdateTimer.stop();
}
} else {
// Network is not active, clear details
if (Nmcli.wirelessDeviceDetails !== null) {
Nmcli.wirelessDeviceDetails = null;
}
}
}
}
} }
function updateDeviceDetails(): void { function updateDeviceDetails(): void {
if (network && Nmcli.active && Nmcli.active.ssid === network.ssid) { if (network && network.ssid) {
Nmcli.getWirelessDeviceDetails("", () => {}); const isActive = network.active || (Nmcli.active && Nmcli.active.ssid === network.ssid);
if (isActive) {
Nmcli.getWirelessDeviceDetails("", () => {});
} else {
Nmcli.wirelessDeviceDetails = null;
}
} else { } else {
Nmcli.wirelessDeviceDetails = null; Nmcli.wirelessDeviceDetails = null;
} }