aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/impl_self.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index b82dfb9..f4c16f3 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -42,7 +42,12 @@ impl App {
42 } 42 }
43 43
44 pub fn delete_by_name(&mut self, name: &str) { 44 pub fn delete_by_name(&mut self, name: &str) {
45 let old_len = self.habits.len();
45 self.habits.retain(|h| h.name() != name); 46 self.habits.retain(|h| h.name() != name);
47 if old_len == self.habits.len() {
48 self.message
49 .set_message(format!("Could not delete habit `{}`", name))
50 }
46 } 51 }
47 52
48 pub fn get_mode(&self) -> ViewMode { 53 pub fn get_mode(&self) -> ViewMode {
@@ -112,6 +117,10 @@ impl App {
112 } 117 }
113 } 118 }
114 119
120 pub fn clear_message(&mut self) {
121 self.message.clear();
122 }
123
115 pub fn status(&self) -> StatusLine { 124 pub fn status(&self) -> StatusLine {
116 let today = chrono::Local::now().naive_utc().date(); 125 let today = chrono::Local::now().naive_utc().date();
117 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>(); 126 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>();