From ac6e691ed65dbc269468ef92c982414b3f5dda61 Mon Sep 17 00:00:00 2001
From: Tim <contact@bytim.eu>
Date: Mon, 24 Feb 2025 18:10:02 +0100
Subject: Add logic for countdown option

---
 src/distractionless/ui/apps/settings.cljd | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/distractionless/ui/apps/settings.cljd')

diff --git a/src/distractionless/ui/apps/settings.cljd b/src/distractionless/ui/apps/settings.cljd
index 8fa57ce..a2c1d4b 100644
--- a/src/distractionless/ui/apps/settings.cljd
+++ b/src/distractionless/ui/apps/settings.cljd
@@ -31,6 +31,10 @@
                                           reloader)))
    .activeColor duconstants/checkbox-active-color))
 
+(defn countdown-setting-value [app config-file]
+  (get-in (dconfig/read-from-file config-file)
+          ["countdowns" (.-packageName app)] 0))
+
 (defn- countdown-setting [app config-file reloader]
   (m/Row
    .children [(m/Text "Countdown, bevor App öffnet (in Sekunden): "
@@ -38,8 +42,7 @@
               (m/Expanded
                .child (m/TextFormField
                        .keyboardType m/TextInputType.number
-                       .initialValue (str (get-in (dconfig/read-from-file config-file)
-                                                  ["countdowns" (.-packageName app)] 0))
+                       .initialValue (str (countdown-setting-value app config-file))
                        .onChanged (fn [new-val]
                                     (dconfig/update-config! config-file
                                                             #(update % "countdowns"
-- 
cgit v1.2.3