From 3c0b2eae58b2003c3b7a1794d3a102708dfe2891 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Tue, 1 Apr 2025 12:46:34 +1100
Subject: cleanup: dispose of file monitors when unneeded

---
 src/modules/sidebar/dashboard.tsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/modules/sidebar/dashboard.tsx')

diff --git a/src/modules/sidebar/dashboard.tsx b/src/modules/sidebar/dashboard.tsx
index bad4695..e445029 100644
--- a/src/modules/sidebar/dashboard.tsx
+++ b/src/modules/sidebar/dashboard.tsx
@@ -34,7 +34,6 @@ const FaceFallback = () => (
 const User = () => {
     const uptime = Variable("").poll(5000, "uptime -p");
     const hasFace = Variable(GLib.file_test(HOME + "/.face", GLib.FileTest.EXISTS));
-    monitorFile(HOME + "/.face", () => hasFace.set(GLib.file_test(HOME + "/.face", GLib.FileTest.EXISTS)));
 
     return (
         <box className="user">
@@ -43,9 +42,12 @@ const User = () => {
                 className="face"
                 setup={self => {
                     self.css = `background-image: url("${HOME}/.face");`;
-                    monitorFile(HOME + "/.face", () => (self.css = `background-image: url("${HOME}/.face");`));
+                    const monitor = monitorFile(HOME + "/.face", () => {
+                        hasFace.set(GLib.file_test(HOME + "/.face", GLib.FileTest.EXISTS));
+                        self.css = `background-image: url("${HOME}/.face");`;
+                    });
+                    self.connect("destroy", () => monitor.cancel());
                 }}
-                onDestroy={() => hasFace.drop()}
             >
                 {bind(hasFace).as(h => (h ? <box visible={false} /> : <FaceFallback />))}
             </box>
-- 
cgit v1.2.3-freya

