From 50cc8de6a266600165e51519952d1cf104733cc8 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 30 Jul 2024 09:37:12 +0300 Subject: [PATCH] feat: hide time if empty --- src/task.rs | 2 +- src/tasks.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/task.rs b/src/task.rs index 57e03ac..f59a3d8 100644 --- a/src/task.rs +++ b/src/task.rs @@ -142,7 +142,7 @@ impl Task { "parentid" => self.parent_id().map(|i| i.to_string()), "state" => self.state().map(|s| s.to_string()), "name" => Some(self.event.content.clone()), - "time" => Some(format!("{}m", self.time_tracked().div(60))), + "time" => Some(self.time_tracked().div(60)).filter(|t| t>&0).map(|t| format!("{}m", t)), "desc" => self.descriptions().last().cloned(), "description" => Some(self.descriptions().join(" ")), "hashtags" => self.filter_tags(|tag| { diff --git a/src/tasks.rs b/src/tasks.rs index dd54e30..dd43f47 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -44,8 +44,8 @@ impl Tasks { properties: vec![ "state".into(), "rtime".into(), + "hashtags".into(), "rpath".into(), - "tags".into(), "desc".into(), ], position: None, @@ -240,7 +240,11 @@ impl Tasks { "rpath" => self.relative_path(task.event.id), "rtime" => { let time = self.total_time_tracked(&task.event.id); - format!("{:02}:{:02}", time / 3600, time / 60 % 60) + if time > 60 { + format!("{:02}:{:02}", time / 3600, time / 60 % 60) + } else { + String::new() + } } prop => task.get(prop).unwrap_or(String::new()), })