aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/impl_self.rs4
-rw-r--r--src/app/impl_view.rs8
2 files changed, 4 insertions, 8 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index 95f1871..7eae853 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -37,6 +37,10 @@ impl App {
37 self.habits.push(h); 37 self.habits.push(h);
38 } 38 }
39 39
40 pub fn list_habits(&self) -> Vec<String> {
41 self.habits.iter().map(|x| x.name()).collect::<Vec<_>>()
42 }
43
40 pub fn delete_by_name(&mut self, name: &str) { 44 pub fn delete_by_name(&mut self, name: &str) {
41 let old_len = self.habits.len(); 45 let old_len = self.habits.len();
42 self.habits.retain(|h| h.name() != name); 46 self.habits.retain(|h| h.name() != name);
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs
index 892b00c..b8c4589 100644
--- a/src/app/impl_view.rs
+++ b/src/app/impl_view.rs
@@ -102,14 +102,6 @@ impl View for App {
102 self.set_focus(Absolute::Down); 102 self.set_focus(Absolute::Down);
103 return EventResult::Consumed(None); 103 return EventResult::Consumed(None);
104 } 104 }
105 Event::Char('d') => {
106 if self.habits.is_empty() {
107 return EventResult::Consumed(None);
108 }
109 self.habits.remove(self.focus);
110 self.focus = self.focus.checked_sub(1).unwrap_or(0);
111 return EventResult::Consumed(None);
112 }
113 Event::Char('w') => { 105 Event::Char('w') => {
114 // helper bind to test write to file 106 // helper bind to test write to file
115 let j = serde_json::to_string_pretty(&self.habits).unwrap(); 107 let j = serde_json::to_string_pretty(&self.habits).unwrap();