From 2a3be003015bac9c6a13549029b9fb4595e88384 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 20 Jul 2020 21:13:45 +0530 Subject: allow "untracking" of habits, closes #18 --- src/habit/count.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/habit/count.rs') diff --git a/src/habit/count.rs b/src/habit/count.rs index 1bdf920..d351758 100644 --- a/src/habit/count.rs +++ b/src/habit/count.rs @@ -84,12 +84,15 @@ impl Habit for Count { if *val > 0 { *val -= 1 } else { - *val = 0 + self.stats.remove(&date); }; } } } else { - self.insert_entry(date, 1); + match event { + TrackEvent::Increment => self.insert_entry(date, 1), + _ => {} + }; } } fn set_view_month_offset(&mut self, offset: u32) { -- cgit v1.2.3