aboutsummaryrefslogtreecommitdiff
path: root/src/habit/bit.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-23 17:53:59 +0100
committerAkshay <[email protected]>2020-07-23 17:53:59 +0100
commit91cb3ebf5b3af666b13f4821ff25f219fdccd7b9 (patch)
treec91d6cffd4d215b325e81bedfdcfdfdcea76a537 /src/habit/bit.rs
parent02bba52346d948e90fbc1b351486f0f1307c243d (diff)
parentd1d1aeb3d5aaa75f262467c5e683e76ce7a844ab (diff)
Merge branch 'feature/windows' of https://github.com/filalex77/dijo into feature/windows
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) {