Skip to main content

cfait/tui/
action.rs

1// SPDX-License-Identifier: GPL-3.0-or-later
2/*
3File: ./src/tui/action.rs
4
5Defines actions and events for TUI interaction and state updates.
6
7This version removes the intent-style Toggle/Mark variants. The TUI now
8performs store mutations locally and emits explicit Create/Update/Delete
9actions for the network actor to persist.
10*/
11
12use crate::model::{CalendarListEntry, Task};
13
14#[derive(Debug, Clone, Copy, PartialEq)]
15pub enum SidebarMode {
16    Calendars,
17    Categories,
18    Locations, // NEW
19}
20
21#[derive(Debug)]
22pub enum Action {
23    SwitchCalendar(String),
24    Refresh,
25    Quit,
26    StartCreateChild(String),
27    MigrateLocal(String, String), // (source_calendar_href, target_calendar_href)
28    ToggleCalendarVisibility(String),
29    IsolateCalendar(String),
30    ToggleTask(String), // UID
31    DuplicateTask(String),
32    DeleteTaskTree(String),
33    PersistBatch(Vec<crate::journal::Action>), // <-- ADD THIS
34}
35
36#[derive(Debug)]
37pub enum AppEvent {
38    ConfigUpdated(Box<crate::config::Config>),
39    CalendarsLoaded(Vec<CalendarListEntry>),
40    TasksLoaded(Vec<(String, Vec<Task>)>),
41    TaskSynced {
42        uid: String,
43        href: String,
44        etag: String,
45        sequence: u32,
46    },
47    /// An event that carries a stable message key plus a localized/human string.
48    /// Use `key` in tests and logic for stable comparisons; `human` is intended
49    /// for UI display (localized).
50    Error(String),
51    Status {
52        key: String,
53        human: String,
54    },
55}