From a0f5d62c8119f11a2b1a8ee6db5be3ebd171cc11 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 25 Aug 2024 13:50:21 +0300 Subject: [PATCH] fix: more intuitive feedback when stopping timetracking --- src/main.rs | 8 +++++--- src/tasks.rs | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index bbf720d..0834ec2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -574,10 +574,12 @@ async fn main() -> Result<()> { match arg { None => tasks.move_to(None), Some(arg) => { - if parse_tracking_stamp(arg).map(|stamp| tasks.track_at(stamp, None)).is_none() { - // So the error message is not covered up - continue; + if parse_tracking_stamp(arg).map(|stamp| tasks.track_at(stamp, None)).is_some() { + let (label, times) = tasks.times_tracked(); + println!("{}\n{}", label.italic(), times.rev().take(15).join("\n")); } + // So the error message is not covered up + continue; } } } diff --git a/src/tasks.rs b/src/tasks.rs index 385abcb..e7ea0df 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -735,7 +735,9 @@ impl Tasks { } pub(crate) fn track_at(&mut self, time: Timestamp, task: Option) -> EventId { - info!("{} from {}", task.map_or(String::from("Stopping time-tracking"), |id| format!("Tracking \"{}\"", self.get_task_title(&id))), format_timestamp_relative(&time)); + info!("{} {}", task.map_or( + String::from("Stopping time-tracking at"), + |id| format!("Tracking \"{}\" from", self.get_task_title(&id))), format_timestamp_relative(&time)); self.submit( build_tracking(task) .custom_created_at(time)