diff --git a/Cargo.lock b/Cargo.lock index 1d2bed2..0772618 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,6 +767,7 @@ dependencies = [ "task-hookrs", "tui", "unicode-width", + "uuid", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 77d1f14..d06b732 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,4 @@ unicode-width = "0.1" tui = { version = "0.10", optional = true, default-features = false } crossterm = { version = "0.17", optional = true, default-features = false } rustyline = "6.3.0" +uuid = { version = "0.8.1", features = ["serde", "v4"] } diff --git a/src/app.rs b/src/app.rs index 92ea5d9..bd12167 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,6 +10,7 @@ use task_hookrs::import::import; use task_hookrs::status::TaskStatus; use task_hookrs::task::Task; use task_hookrs::uda::UDAValue; +use uuid::Uuid; use chrono::{Local, NaiveDateTime, TimeZone}; @@ -741,6 +742,24 @@ impl TTApp { } } + fn task_by_index(&self, i: usize) -> Option { + let tasks = &self.tasks.lock().unwrap(); + if i > tasks.len() { + None + } else { + Some(tasks[i].clone()) + } + } + + fn task_by_uuid(&self, uuid: Uuid) -> Option { + let tasks = &self.tasks.lock().unwrap(); + let m = tasks.iter().find(|t| *t.uuid() == uuid); + match m { + Some(v) => Some(v.clone()), + None => None + } + } + fn draw_task_report(&mut self, f: &mut Frame, rect: Rect) { let (tasks, headers, widths) = self.task_report(); if tasks.is_empty() {