From 5032b4db93271057d498dc2e4749e5d8fd4edf28 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 21 Nov 2024 10:56:52 +0100 Subject: [PATCH] refactor(tasks): omit empty descriptions preparation for state update notes --- src/task.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/task.rs b/src/task.rs index 5ea1407..d53c138 100644 --- a/src/task.rs +++ b/src/task.rs @@ -98,7 +98,8 @@ impl Task { /// Description items, ordered newest to oldest pub(crate) fn descriptions(&self) -> impl DoubleEndedIterator + '_ { - self.description_events().map(|e| &e.content) + self.description_events() + .filter_map(|e| Some(&e.content).take_if(|s| !s.trim().is_empty())) } pub(crate) fn is_task_kind(&self) -> bool { @@ -222,10 +223,7 @@ impl Task { .map(|e| format!("{} kind {} \"{}\"", e.created_at, e.kind, e.content)) .collect_vec() )), - "descriptions" => Some(format!( - "{:?}", - self.descriptions().collect_vec() - )), + "descriptions" => Some(format!("{:?}", self.descriptions().collect_vec())), _ => { warn!("Unknown task property {}", property); None