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()),
"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| {

View File

@ -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()),
})