diff options
| -rw-r--r-- | src/main.rs | 3 | ||||
| -rw-r--r-- | src/state/threads.rs | 25 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index a518534..53d6eaf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,8 @@ use termion::screen::AlternateScreen; fn main() { let stdin = stdin(); - let screen = AlternateScreen::from(stdout().into_raw_mode().unwrap()); + let screen = stdout().into_raw_mode().unwrap(); + // let screen = AlternateScreen::from(screen); // hide the cursor let mut screen = termion::cursor::HideCursor::from(screen); diff --git a/src/state/threads.rs b/src/state/threads.rs index f3d8721..4248d93 100644 --- a/src/state/threads.rs +++ b/src/state/threads.rs @@ -1,5 +1,7 @@ +use crate::db; use super::State; +use notmuch::DatabaseMode; use std::io::Write; use termion::{color, event::Key}; @@ -11,7 +13,22 @@ pub struct Threads { pub struct Thread { subject: String, authors: Vec<String>, - id: String, + _id: String, + messages: Vec<String>, +} + +impl Thread { + pub fn remove_tag(&self, tag: &str) { + let db = db::open(DatabaseMode::ReadWrite).unwrap(); + for m_id in self.messages.iter() { + db + .find_message(m_id) + .unwrap() + .unwrap() + .remove_tag(tag) + .unwrap(); + } + } } impl<'d, 'q> Threads { @@ -19,7 +36,8 @@ impl<'d, 'q> Threads { let threads = threads.map(|t| Thread { subject: t.subject().to_string(), authors: t.authors().clone(), - id: t.id().to_string(), + _id: t.id().to_string(), + messages: t.messages().map(|m| m.id().to_string()).collect(), }).collect(); Self { @@ -36,6 +54,9 @@ impl<'d, 'q> Threads { match key { Key::Char('j') => self.i += 1, Key::Char('k') => self.i -= 1, + Key::Char('i') => { + self.threads[self.i as usize].remove_tag("inbox"); + } _ => (), } self.i = self.i.rem_euclid(self.threads.len() as isize); |
