aboutsummaryrefslogtreecommitdiff
path: root/src/habit/count.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-21 05:13:32 +0000
committerAkshay <[email protected]>2021-02-21 05:13:32 +0000
commit38d9dfee224ebcd088c0ebecd9e1243994eea409 (patch)
tree1215766f07b1c2eaf68f20aba284e710eb9a24a3 /src/habit/count.rs
parentad5bf181a176e64c9f70a292cad870e6e8110f09 (diff)
parent53f7a679a0cf7a510de13d67cf370988f71c0d08 (diff)
Merge branch 'cursor' into master
Diffstat (limited to 'src/habit/count.rs')
-rw-r--r--src/habit/count.rs25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/habit/count.rs b/src/habit/count.rs
index d351758..09fd399 100644
--- a/src/habit/count.rs
+++ b/src/habit/count.rs
@@ -1,11 +1,12 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2use std::default::Default;
2 3
3use chrono::NaiveDate; 4use chrono::NaiveDate;
4use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
5 6
6use crate::habit::prelude::default_auto; 7use crate::habit::prelude::default_auto;
7use crate::habit::traits::Habit; 8use crate::habit::traits::Habit;
8use crate::habit::{TrackEvent, ViewMode}; 9use crate::habit::{InnerData, TrackEvent};
9 10
10#[derive(Debug, Serialize, Deserialize)] 11#[derive(Debug, Serialize, Deserialize)]
11pub struct Count { 12pub struct Count {
@@ -17,10 +18,7 @@ pub struct Count {
17 auto: bool, 18 auto: bool,
18 19
19 #[serde(skip)] 20 #[serde(skip)]
20 view_month_offset: u32, 21 inner_data: InnerData,
21
22 #[serde(skip)]
23 view_mode: ViewMode,
24} 22}
25 23
26impl Count { 24impl Count {
@@ -30,8 +28,7 @@ impl Count {
30 stats: HashMap::new(), 28 stats: HashMap::new(),
31 goal, 29 goal,
32 auto, 30 auto,
33 view_month_offset: 0, 31 inner_data: Default::default(),
34 view_mode: ViewMode::Day,
35 }; 32 };
36 } 33 }
37} 34}
@@ -95,17 +92,11 @@ impl Habit for Count {
95 }; 92 };
96 } 93 }
97 } 94 }
98 fn set_view_month_offset(&mut self, offset: u32) { 95 fn inner_data_ref(&self) -> &InnerData {
99 self.view_month_offset = offset; 96 &self.inner_data
100 }
101 fn view_month_offset(&self) -> u32 {
102 self.view_month_offset
103 }
104 fn set_view_mode(&mut self, mode: ViewMode) {
105 self.view_mode = mode;
106 } 97 }
107 fn view_mode(&self) -> ViewMode { 98 fn inner_data_mut_ref(&mut self) -> &mut InnerData {
108 self.view_mode 99 &mut self.inner_data
109 } 100 }
110 fn is_auto(&self) -> bool { 101 fn is_auto(&self) -> bool {
111 self.auto 102 self.auto