From 42c3278f8283bb632150055ea8c557db63789546 Mon Sep 17 00:00:00 2001 From: xzeldon Date: Fri, 6 Sep 2024 02:50:05 +0300 Subject: [PATCH] chore: update todo list, add imports - use std::time::{Duration, Instant} for convenience --- README.md | 1 + src/tray.rs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d1a8c8d..b8e7b92 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ To build, you must have [Rust](https://www.rust-lang.org/) and - [ ] Force update devices button in tray menu - [ ] Colored tray icons for different battery levels - [x] Show log window button in tray menu + - [ ] Further reduce CPU usage by using Event Loop Proxy events (more info [here](https://github.com/tauri-apps/tray-icon/issues/83#issuecomment-1697773065)) - [ ] Prebuilt Binary - [ ] Command Line Arguments for update frequency - [ ] Support for other Razer Devices (I only have DeathAdder V3 Pro, so I won't be able to test it with other devices) diff --git a/src/tray.rs b/src/tray.rs index 5dcf7e1..c618e05 100644 --- a/src/tray.rs +++ b/src/tray.rs @@ -3,7 +3,7 @@ use std::{ rc::Rc, sync::{mpsc, Arc, Mutex}, thread, - time::Duration, + time::{Duration, Instant}, }; use crate::manager::DeviceManager; @@ -18,8 +18,8 @@ use winapi::um::{ winuser::{self, ShowWindow}, }; -const BATTERY_UPDATE_INTERVAL: std::time::Duration = std::time::Duration::from_secs(60); -const DEVICE_FETCH_INTERVAL: std::time::Duration = std::time::Duration::from_secs(5); +const BATTERY_UPDATE_INTERVAL: Duration = Duration::from_secs(60); +const DEVICE_FETCH_INTERVAL: Duration = Duration::from_secs(5); #[derive(Debug)] pub struct MemoryDevice { @@ -194,7 +194,7 @@ impl TrayApp { let menu_channel = MenuEvent::receiver(); - let mut last_update = std::time::Instant::now(); + let mut last_update = Instant::now(); let update_interval = Duration::from_millis(100); event_loop.run(move |event, _, control_flow| { @@ -237,7 +237,7 @@ impl TrayApp { } } - last_update = std::time::Instant::now(); + last_update = Instant::now(); } } _ => (),