From 72626524c4a1c7d6642bc170520913273acb1a5c Mon Sep 17 00:00:00 2001 From: Solstice Date: Tue, 9 Jun 2026 00:13:03 -0700 Subject: feat: backend timer logic and data persistence --- src-tauri/src/state.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src-tauri/src/state.rs (limited to 'src-tauri/src/state.rs') diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs new file mode 100644 index 0000000..9cd3698 --- /dev/null +++ b/src-tauri/src/state.rs @@ -0,0 +1,45 @@ +use std::path::PathBuf; +use std::sync::{Arc, Mutex}; +use serde::{Deserialize, Serialize}; +use crate::storage::AppData; + +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum TimerPhase { + Work, + ShortBreak, + LongBreak, +} + +#[derive(Debug, Clone, Serialize)] +pub struct TimerState { + pub phase: TimerPhase, + pub remaining_secs: u64, + pub total_secs: u64, + pub running: bool, + pub session_count: u32, + pub current_task_id: Option, +} + +/// Wrapper held in Tauri managed state — contains the Arc so commands can clone it. +pub struct TimerStateWrapper(pub Arc>); + +/// Wrapper for AppData — contains the Arc and the data directory path. +pub struct AppDataWrapper { + pub data: Arc>, + #[allow(dead_code)] + pub data_dir: PathBuf, +} + +impl TimerState { + pub fn new(work_duration_secs: u64) -> Self { + Self { + phase: TimerPhase::Work, + remaining_secs: work_duration_secs, + total_secs: work_duration_secs, + running: false, + session_count: 0, + current_task_id: None, + } + } +} -- cgit v1.3-2-g0d8e