Add error notifications for network menu.

This commit is contained in:
Jas Singh
2024-06-29 19:50:04 -07:00
parent 47b3f1c74e
commit c2d60bcf94
9 changed files with 64 additions and 26 deletions

View File

@@ -14,7 +14,7 @@ const renderWapStaging = (self, network, staging, connecting) => {
hexpand: true,
children: [
Widget.Icon({
class_name: `network-icon wifi `,
class_name: `network-icon wifi`,
icon: `${staging.value.iconName}`,
}),
Widget.Box({
@@ -63,6 +63,10 @@ const renderWapStaging = (self, network, staging, connecting) => {
console.error(
`Failed to connect to wifi: ${staging.value.ssid}... ${err}`,
);
Utils.notify({
summary: "Network",
body: err,
});
})
.then(() => {
connecting.value = "";

View File

@@ -39,6 +39,13 @@ const renderWAPs = (self, network, staging, connecting) => {
return wap.bssid === staging.value.bssid;
};
const isDisconnecting = (wap) => {
if (wap.ssid === network.wifi.ssid) {
return network.wifi.state.toLowerCase() === "deactivating";
}
return false;
};
const filteredWAPs = WAPs.filter(
(ap) => ap.ssid !== "Unknown" && !isInStaging(ap),
).sort((a, b) => {
@@ -83,6 +90,11 @@ const renderWAPs = (self, network, staging, connecting) => {
.includes("secrets were required, but not provided")
) {
staging.value = ap;
} else {
Utils.notify({
summary: "Network",
body: err,
});
}
connecting.value = "";
});
@@ -128,7 +140,7 @@ const renderWAPs = (self, network, staging, connecting) => {
Widget.Revealer({
hpack: "end",
vpack: "start",
reveal_child: ap.bssid === connecting.value,
reveal_child: ap.bssid === connecting.value || isDisconnecting(ap),
child: Widget.Spinner({
vpack: "start",
class_name: "spinner wap",
@@ -154,11 +166,14 @@ const renderWAPs = (self, network, staging, connecting) => {
Utils.execAsync(
`nmcli connection delete ${connectionId} "${ap.ssid}"`,
).catch((err) =>
console.error(
`Error while forgetting "${ap.ssid}": ${err}`,
),
);
)
.then(() => (connecting.value = ""))
.catch((err) => {
connecting.value = "";
console.error(
`Error while forgetting "${ap.ssid}": ${err}`,
);
});
},
);
},