Something went wrong. Try again.
My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120use std::time::Duration;
use crossterm::event::KeyEvent;use entity::NanoId;use fil_api::ChangeSet;use fil_core::ZettelId;
// wire types, carried in messagespub use crate::client::{Snapshot, TodoUpdate};
/// All messages the event loop feeds into `update`.#[derive(Debug)]pub enum Msg { Tick, Resize, Key(KeyEvent), /// The event stream to the daemon is open. EventsConnected, /// The event stream closed or couldn't open; why, for the status line. EventsDisconnected(String), /// The daemon published changes. Changes(ChangeSet), /// The daemon dropped changes this client was too slow to receive. Resync, SnapshotLoaded(Snapshot), SnapshotFailed(String), /// A zettel's body, or why it couldn't be fetched, for fetch `ticket`. BodyFetched { id: ZettelId, ticket: u64, body: Result<String, String>, }, /// The daemon's ranking for search `seq`. SearchResults { seq: u64, results: Result<Vec<ZettelId>, String>, }, /// Raw file contents of `id`, front matter included. FileFetched { id: ZettelId, contents: String, }, FileFetchFailed(String), /// The editor exited. `result` holds the edited temp file's contents, or /// why the editor couldn't run. EditorClosed { id: ZettelId, original: String, result: Result<String, String>, }, ZettelSaved, ZettelSaveFailed(String), /// A zettel was created; select it once its change arrives and open it. ZettelCreated(ZettelId), ZettelCreateFailed(String), /// A task or group was created; select it once its change arrives. TodoCreated(NanoId), /// A todo item was toggled or edited. TodoUpdated, TodoMutationFailed(String),}
/// Side effects `update` hands back to the event loop.#[derive(Debug)]pub enum Cmd { /// Opens the event stream to the daemon after waiting `after`; it /// reports back until it closes. The wait is the reconnect backoff. Subscribe { after: Duration, }, /// Fetches the full state, to (re)sync from, after waiting `after`; the /// wait is the retry backoff after a failed fetch. FetchSnapshot { after: Duration, }, /// Fetches `id`'s body to show; `ticket` tells a stale response apart. FetchBody { id: ZettelId, ticket: u64, }, /// Asks the daemon to rank zettels for `query`. Search { seq: u64, query: String, }, /// Fetches the raw file for `id` from the daemon. FetchFile(ZettelId), /// Dumps `contents` to a temp file and hands the terminal to the editor /// on it. Run inline by the event loop rather than spawned, since it /// needs exclusive use of the TUI. OpenEditor { id: ZettelId, contents: String, }, /// Hands the terminal back to the shell (Ctrl-Z). Run inline by the /// event loop, like `OpenEditor`. Suspend, /// Uploads the edited file for `id`; the daemon overwrites it. SaveFile { id: ZettelId, contents: String, }, CreateZettel { title: String, }, CreateTask { name: String, group_id: NanoId, }, /// `parent_id: None` creates a top-level group. CreateGroup { name: String, parent_id: Option<NanoId>, }, /// Flips the task between finished and unfinished. ToggleTask(NanoId), /// Saves an inspector edit. UpdateTodo(TodoUpdate),}