1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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<String>,
}
/// Wrapper held in Tauri managed state — contains the Arc so commands can clone it.
pub struct TimerStateWrapper(pub Arc<Mutex<TimerState>>);
/// Wrapper for AppData — contains the Arc and the data directory path.
pub struct AppDataWrapper {
pub data: Arc<Mutex<AppData>>,
#[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,
}
}
}
|