fix(ags): prevent activeAccessPoint from being null
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
0af7f8b1e3
commit
c648667ef3
1 changed files with 19 additions and 13 deletions
|
@ -2,11 +2,12 @@ import { bind, Variable } from 'astal';
|
|||
import { Gtk } from 'astal/gtk3';
|
||||
|
||||
import AstalNetwork from 'gi://AstalNetwork';
|
||||
const Network = AstalNetwork.get_default();
|
||||
|
||||
|
||||
export default () => {
|
||||
const Hovered = Variable(false);
|
||||
// TODO: do this everywhere else
|
||||
const network = AstalNetwork.get_default();
|
||||
|
||||
return (
|
||||
<button
|
||||
|
@ -16,32 +17,37 @@ export default () => {
|
|||
onHover={() => Hovered.set(true)}
|
||||
onHoverLost={() => Hovered.set(false)}
|
||||
>
|
||||
{bind(Network, 'primary').as((primary) => {
|
||||
{bind(network, 'primary').as((primary) => {
|
||||
if (primary === AstalNetwork.Primary.UNKNOWN) {
|
||||
return (<icon icon="network-wireless-signal-none-symbolic" />);
|
||||
}
|
||||
else if (primary === AstalNetwork.Primary.WIFI) {
|
||||
const Wifi = Network.get_wifi();
|
||||
const Wifi = network.get_wifi();
|
||||
|
||||
if (!Wifi) { return; }
|
||||
|
||||
return (
|
||||
<box>
|
||||
<icon icon={bind(Wifi, 'iconName')} />
|
||||
{/* Make sure the AP is there before binding to it */}
|
||||
{bind(Wifi, 'accessPoints').as((aps) => aps.length !== 0 && (
|
||||
<>
|
||||
<icon icon={bind(Wifi, 'iconName')} />
|
||||
|
||||
<revealer
|
||||
revealChild={bind(Hovered)}
|
||||
transitionType={Gtk.RevealerTransitionType.SLIDE_LEFT}
|
||||
>
|
||||
{bind(Wifi, 'activeAccessPoint').as((ap) => (
|
||||
<label label={bind(ap, 'ssid')} />
|
||||
))}
|
||||
</revealer>
|
||||
<revealer
|
||||
revealChild={bind(Hovered)}
|
||||
transitionType={Gtk.RevealerTransitionType.SLIDE_LEFT}
|
||||
>
|
||||
{bind(Wifi, 'activeAccessPoint').as((ap) => ap && (
|
||||
<label label={bind(ap, 'ssid')} />
|
||||
))}
|
||||
</revealer>
|
||||
</>
|
||||
))}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
else {
|
||||
const Wired = Network.get_wired();
|
||||
const Wired = network.get_wired();
|
||||
|
||||
if (!Wired) { return; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue