diff options
Diffstat (limited to 'src/habit/count.rs')
-rw-r--r-- | src/habit/count.rs | 25 |
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 @@ | |||
1 | use std::collections::HashMap; | 1 | use std::collections::HashMap; |
2 | use std::default::Default; | ||
2 | 3 | ||
3 | use chrono::NaiveDate; | 4 | use chrono::NaiveDate; |
4 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
5 | 6 | ||
6 | use crate::habit::prelude::default_auto; | 7 | use crate::habit::prelude::default_auto; |
7 | use crate::habit::traits::Habit; | 8 | use crate::habit::traits::Habit; |
8 | use crate::habit::{TrackEvent, ViewMode}; | 9 | use crate::habit::{InnerData, TrackEvent}; |
9 | 10 | ||
10 | #[derive(Debug, Serialize, Deserialize)] | 11 | #[derive(Debug, Serialize, Deserialize)] |
11 | pub struct Count { | 12 | pub 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 | ||
26 | impl Count { | 24 | impl 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 |