aboutsummaryrefslogtreecommitdiff
path: root/src/habit/bit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/habit/bit.rs')
-rw-r--r--src/habit/bit.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/habit/bit.rs b/src/habit/bit.rs
index 3386182..8fa14c2 100644
--- a/src/habit/bit.rs
+++ b/src/habit/bit.rs
@@ -100,11 +100,22 @@ impl Habit for Bit {
100 fn goal(&self) -> u32 { 100 fn goal(&self) -> u32 {
101 return 1; 101 return 1;
102 } 102 }
103 fn modify(&mut self, date: NaiveDate, _: TrackEvent) { 103 fn modify(&mut self, date: NaiveDate, event: TrackEvent) {
104 if let Some(val) = self.stats.get_mut(&date) { 104 if let Some(val) = self.stats.get_mut(&date) {
105 *val = (val.0 ^ true).into(); 105 match event {
106 TrackEvent::Increment => *val = (val.0 ^ true).into(),
107 TrackEvent::Decrement => {
108 if val.0 {
109 *val = false.into();
110 } else {
111 self.stats.remove(&date);
112 }
113 }
114 }
106 } else { 115 } else {
107 self.insert_entry(date, CustomBool(true)); 116 if event == TrackEvent::Increment {
117 self.insert_entry(date, CustomBool(true));
118 }
108 } 119 }
109 } 120 }
110 fn set_view_month_offset(&mut self, offset: u32) { 121 fn set_view_month_offset(&mut self, offset: u32) {