aboutsummaryrefslogtreecommitdiffstats
path: root/src/state/threads.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/threads.rs')
-rw-r--r--src/state/threads.rs25
1 files changed, 23 insertions, 2 deletions
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);