Add error notifications for network menu.
This commit is contained in:
@@ -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 = "";
|
||||
|
||||
@@ -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}`,
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -82,8 +82,13 @@ export default () => {
|
||||
vertical: true,
|
||||
setup: (self) => {
|
||||
self.hook(notifs, () => {
|
||||
console.log(JSON.stringify(notifs, null, 2));
|
||||
|
||||
const notifHasImg = (notif) => {
|
||||
return notif.image !== undefined && notif.image.length;
|
||||
};
|
||||
const imageContainer = (notif) => {
|
||||
if (notif.image !== undefined) {
|
||||
if (notifHasImg(notif)) {
|
||||
return [
|
||||
Widget.Box({
|
||||
class_name: "notification-card-image-container menu",
|
||||
@@ -138,7 +143,9 @@ export default () => {
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
return [Widget.Box({
|
||||
class_name: "spacer"
|
||||
})];
|
||||
};
|
||||
|
||||
const NotificationIcon = ({
|
||||
@@ -208,7 +215,7 @@ export default () => {
|
||||
vpack: "center",
|
||||
vertical: true,
|
||||
hexpand: true,
|
||||
class_name: `notification-card-content ${notif.image === undefined ? "noimg" : " menu"}`,
|
||||
class_name: `notification-card-content ${!notifHasImg(notif) ? "noimg" : " menu"}`,
|
||||
children: [
|
||||
Widget.Box({
|
||||
vertical: false,
|
||||
@@ -226,8 +233,9 @@ export default () => {
|
||||
hpack: "start",
|
||||
hexpand: true,
|
||||
vexpand: true,
|
||||
max_width_chars:
|
||||
notif.image === undefined ? 27 : 20,
|
||||
max_width_chars: !notifHasImg(notif)
|
||||
? 27
|
||||
: 20,
|
||||
truncate: "end",
|
||||
wrap: true,
|
||||
label: notif["summary"],
|
||||
@@ -255,8 +263,9 @@ export default () => {
|
||||
justification: "left",
|
||||
truncate: "end",
|
||||
lines: 2,
|
||||
max_width_chars:
|
||||
notif.image === undefined ? 35 : 28,
|
||||
max_width_chars: !notifHasImg(notif)
|
||||
? 35
|
||||
: 28,
|
||||
wrap: true,
|
||||
class_name:
|
||||
"notification-card-body-label menu",
|
||||
|
||||
Reference in New Issue
Block a user