From ebcccc4ae13f690220374497f932f58ec5fd7cfd Mon Sep 17 00:00:00 2001
From: Aylur <k.demeter@protonmail.com>
Date: Sat, 28 Dec 2024 01:33:32 +0100
Subject: fix: examples without wifi

---
 examples/js/simple-bar/widget/Bar.tsx | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

(limited to 'examples/js/simple-bar/widget/Bar.tsx')

diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx
index c109aec..b08ea27 100644
--- a/examples/js/simple-bar/widget/Bar.tsx
+++ b/examples/js/simple-bar/widget/Bar.tsx
@@ -25,13 +25,19 @@ function SysTray() {
 }
 
 function Wifi() {
-    const { wifi } = Network.get_default()
+    const network = Network.get_default()
+    const wifi = bind(network, "wifi")
+
+    return <box visible={wifi.as(Boolean)}>
+        {wifi.as(wifi => wifi && (
+            <icon
+                tooltipText={bind(wifi, "ssid").as(String)}
+                className="Wifi"
+                icon={bind(wifi, "iconName")}
+            />
+        ))}
+    </box>
 
-    return <icon
-        tooltipText={bind(wifi, "ssid").as(String)}
-        className="Wifi"
-        icon={bind(wifi, "iconName")}
-    />
 }
 
 function AudioSlider() {
-- 
cgit v1.2.3

