about summary refs log tree commit diff
path: root/src/ui/window.rs
diff options
context:
space:
mode:
authorRicky Kresslein <ricky@kressle.in>2022-02-23 22:54:50 +0100
committerRicky Kresslein <ricky@kressle.in>2022-02-23 22:54:50 +0100
commitde4ea78d38007a2efda4cbd03d0207fa27decbf4 (patch)
tree77f642be49be3656276628b8fc885a5f5d169c86 /src/ui/window.rs
parent2a8e1c75863bc84c55eadcff1f3adb42d409d180 (diff)
downloadFurtherance-de4ea78d38007a2efda4cbd03d0207fa27decbf4.tar.zst
- Clearly states idle notify works in Gnome only
- Fixed bug idle preference only updated on start
- Added dark theme switch
Diffstat (limited to 'src/ui/window.rs')
-rw-r--r--src/ui/window.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 92c8282..7c1e8cc 100644
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -25,7 +25,6 @@ use std::rc::Rc;
 use std::cell::RefCell;
 use chrono::{DateTime, Local, Duration as ChronDur};
 use dbus::blocking::Connection;
-use once_cell::unsync::OnceCell;
 
 use crate::ui::FurHistoryBox;
 use crate::FurtheranceApplication;
@@ -53,7 +52,6 @@ mod imp {
         #[template_child]
         pub toast_overlay: TemplateChild<adw::ToastOverlay>,
 
-        pub notify_of_idle: OnceCell<u64>,
         pub stored_idle: Mutex<u64>,
         pub idle_notified: Mutex<bool>,
         pub idle_time_reached: Mutex<bool>,
@@ -220,9 +218,6 @@ impl FurtheranceWindow {
 
     fn setup_settings(&self) {
         let imp = imp::FurtheranceWindow::from_instance(self);
-        // Get user setting idle-time in minutes and convert it to seconds
-        imp.notify_of_idle.set((settings_manager::get_int("idle-time") * 60) as u64)
-            .expect("Failed to set notify_of_idle");
         self.reset_vars();
 
         // Enter starts timer
@@ -249,7 +244,7 @@ impl FurtheranceWindow {
         let idle_time = self.get_idle_time().unwrap();
 
         // If user was idle and has now returned...
-        if idle_time < *imp.notify_of_idle.get().unwrap()
+        if idle_time < (settings_manager::get_int("idle-time") * 60) as u64
             && *imp.idle_time_reached.lock().unwrap()
             && !*imp.idle_notified.lock().unwrap() {
 
@@ -259,12 +254,12 @@ impl FurtheranceWindow {
         *imp.stored_idle.lock().unwrap() = idle_time;
 
         // If user is idle but has not returned...
-        if *imp.stored_idle.lock().unwrap() >= *imp.notify_of_idle.get().unwrap()
+        if *imp.stored_idle.lock().unwrap() >= (settings_manager::get_int("idle-time") * 60) as u64
             && !*imp.idle_time_reached.lock().unwrap() {
 
             *imp.idle_time_reached.lock().unwrap() = true;
             let true_idle_start_time = Local::now() -
-                ChronDur::seconds(*imp.notify_of_idle.get().unwrap() as i64);
+                ChronDur::seconds((settings_manager::get_int("idle-time") * 60) as i64);
             *imp.idle_start_time.lock().unwrap() = true_idle_start_time.to_rfc3339();
         }
     }