diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-04-28 23:49:03 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-04-28 23:49:03 +0200 |
| commit | 4a33cd02bef5fba633d99cf0e8f5ca55a25e8384 (patch) | |
| tree | d35356f1cd59480941d18b0cc9e3ec5369214881 /src/state/threads.rs | |
| parent | 78fc967b36d83c1a29bf15f3e8686feaf842b68b (diff) | |
| download | mail-4a33cd02bef5fba633d99cf0e8f5ca55a25e8384.tar.gz | |
try look for sent messages
Diffstat (limited to 'src/state/threads.rs')
| -rw-r--r-- | src/state/threads.rs | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/state/threads.rs b/src/state/threads.rs index b6fddbb..be566e5 100644 --- a/src/state/threads.rs +++ b/src/state/threads.rs @@ -9,7 +9,7 @@ pub struct Threads { threads: Vec<Thread>, i: usize, - query: Option<String>, + query: String, } pub struct Thread { @@ -42,29 +42,29 @@ impl<'d, 'q> Thread { } } -impl<'d, 'q> Threads { - pub fn from_query(query: Option<String>, threads: notmuch::Threads<'d, 'q>) -> Self { - Self { - threads: threads.map(Thread::new).collect(), +impl Threads { + pub fn from_query(query: String) -> Self { + let mut res = Self { + threads: Vec::new(), i: 0, query, - } + }; + res.reload(); + res } pub fn reload(&mut self) { - if let Some(query) = &self.query { - self.threads = db::open(DatabaseMode::ReadOnly) - .unwrap() - .create_query(query) - .unwrap() - .search_threads() - .unwrap() - .map(Thread::new) - .collect(); - } + self.threads = db::open(DatabaseMode::ReadOnly) + .unwrap() + .create_query(&self.query) + .unwrap() + .search_threads() + .unwrap() + .map(Thread::new) + .collect(); } - pub fn init<W: Write>(&mut self, out: &mut W) { + pub fn init<W: Write>(&self, out: &mut W) { draw(&self, out); } @@ -80,6 +80,11 @@ impl<'d, 'q> Threads { Key::Char('i') => { self.threads[self.i].remove_tag("inbox"); } + Key::Char('s') => { + let sent = Threads::from_query(String::from("tag:sent")); + sent.init(out); + return Some(State::Threads(sent)); + } Key::Char('r') => self.reload(), _ => (), } |
