feat: hide time if empty

This commit is contained in:
xeruf 2024-07-30 09:37:12 +03:00
parent fbbdd5eef8
commit 50cc8de6a2
2 changed files with 7 additions and 3 deletions

View File

@ -142,7 +142,7 @@ impl Task {
"parentid" => self.parent_id().map(|i| i.to_string()), "parentid" => self.parent_id().map(|i| i.to_string()),
"state" => self.state().map(|s| s.to_string()), "state" => self.state().map(|s| s.to_string()),
"name" => Some(self.event.content.clone()), "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(), "desc" => self.descriptions().last().cloned(),
"description" => Some(self.descriptions().join(" ")), "description" => Some(self.descriptions().join(" ")),
"hashtags" => self.filter_tags(|tag| { "hashtags" => self.filter_tags(|tag| {

View File

@ -44,8 +44,8 @@ impl Tasks {
properties: vec![ properties: vec![
"state".into(), "state".into(),
"rtime".into(), "rtime".into(),
"hashtags".into(),
"rpath".into(), "rpath".into(),
"tags".into(),
"desc".into(), "desc".into(),
], ],
position: None, position: None,
@ -240,7 +240,11 @@ impl Tasks {
"rpath" => self.relative_path(task.event.id), "rpath" => self.relative_path(task.event.id),
"rtime" => { "rtime" => {
let time = self.total_time_tracked(&task.event.id); let time = self.total_time_tracked(&task.event.id);
if time > 60 {
format!("{:02}:{:02}", time / 3600, time / 60 % 60) format!("{:02}:{:02}", time / 3600, time / 60 % 60)
} else {
String::new()
}
} }
prop => task.get(prop).unwrap_or(String::new()), prop => task.get(prop).unwrap_or(String::new()),
}) })