diff --git a/src-tauri/src/app_state.rs b/src-tauri/src/app_state.rs index 2b4104b..ce49395 100644 --- a/src-tauri/src/app_state.rs +++ b/src-tauri/src/app_state.rs @@ -20,18 +20,18 @@ impl ClockAnchor { instant.duration_since(self.boot_instant).as_millis() + self.boot_epoch_ms } } - +//TODO: implement the handling of multiple countdowns #[derive(Debug)] pub struct AppState { pub clock_anchor: ClockAnchor, - pub countdowns: Vec, + pub countdown_service: CountdownService, } impl AppState { pub fn new() -> Self { Self { clock_anchor: ClockAnchor::new(), - countdowns: vec![CountdownService::new()], + countdown_service: CountdownService::default(), } } } diff --git a/src-tauri/src/countdown/service.rs b/src-tauri/src/countdown/service.rs index 1adb186..6f0ff27 100644 --- a/src-tauri/src/countdown/service.rs +++ b/src-tauri/src/countdown/service.rs @@ -7,14 +7,16 @@ use crate::countdown::model::{Countdown, CountdownError}; #[derive(Debug)] pub struct CountdownService { countdown: Mutex, - next_id: u64, } impl CountdownService { - pub fn new() -> Self { + pub fn default() -> Self { + Self::new(0, "Countdown0", Duration::new(600, 0)) + } + + pub fn new(id: u64, label: &str, duration: Duration) -> Self { Self { - countdown: Mutex::new(Countdown::new(0, "Countdown0", Duration::new(600, 0))), - next_id: 1, + countdown: Mutex::new(Countdown::new(id, label, duration)), } }