diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2018-08-12 16:55:45 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:28 +0300 |
commit | 5889494e9e4d6c51aa87e6433f2dfdbfb8b4846a (patch) | |
tree | ac78d166e6b97d2b2515478d9c4490dc06ce2698 /ui/src/components/mail/view | |
parent | e316640f682fa05d0b12168219a2dd8000fb4ec5 (diff) |
Move backend logic to backend and keep Envelope abstract
Diffstat (limited to 'ui/src/components/mail/view')
-rw-r--r-- | ui/src/components/mail/view/mod.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ui/src/components/mail/view/mod.rs b/ui/src/components/mail/view/mod.rs index 25c7733e..724e0657 100644 --- a/ui/src/components/mail/view/mod.rs +++ b/ui/src/components/mail/view/mod.rs @@ -303,11 +303,12 @@ impl Component for MailView { if self.dirty { let mailbox_idx = self.coordinates; // coordinates are mailbox idxs - let mailbox = &mut context.accounts[mailbox_idx.0][mailbox_idx.1] + let mailbox = &context.accounts[mailbox_idx.0][mailbox_idx.1] .as_ref() .unwrap(); let envelope: &Envelope = &mailbox.collection[envelope_idx]; - let body = envelope.body(); + let op = context.accounts[mailbox_idx.0].backend.operation(envelope.hash()); + let body = envelope.body(op); match self.mode { ViewMode::Attachment(aidx) if body.attachments()[aidx].is_html() => { self.subview = Some(Box::new(HtmlView::new(decode( @@ -372,9 +373,9 @@ impl Component for MailView { self.cmd_buf.clear(); { - let accounts = &mut context.accounts; + let accounts = &context.accounts; let threaded = accounts[self.coordinates.0].runtime_settings.threaded; - let mailbox = &mut accounts[self.coordinates.0][self.coordinates.1] + let mailbox = &accounts[self.coordinates.0][self.coordinates.1] .as_ref() .unwrap(); let envelope_idx: usize = if threaded { @@ -384,7 +385,8 @@ impl Component for MailView { }; let envelope: &Envelope = &mailbox.collection[envelope_idx]; - if let Some(u) = envelope.body().attachments().get(lidx) { + let op = context.accounts[self.coordinates.0].backend.operation(envelope.hash()); + if let Some(u) = envelope.body(op).attachments().get(lidx) { match u.content_type().0 { ContentType::Text { .. } => { self.mode = ViewMode::Attachment(lidx); @@ -443,9 +445,9 @@ impl Component for MailView { let lidx = self.cmd_buf.parse::<usize>().unwrap(); self.cmd_buf.clear(); let url = { - let accounts = &mut context.accounts; + let accounts = &context.accounts; let threaded = accounts[self.coordinates.0].runtime_settings.threaded; - let mailbox = &mut accounts[self.coordinates.0][self.coordinates.1] + let mailbox = &accounts[self.coordinates.0][self.coordinates.1] .as_ref() .unwrap(); let envelope_idx: usize = if threaded { @@ -456,7 +458,8 @@ impl Component for MailView { let envelope: &Envelope = &mailbox.collection[envelope_idx]; let finder = LinkFinder::new(); - let mut t = envelope.body().text().to_string(); + let op = context.accounts[self.coordinates.0].backend.operation(envelope.hash()); + let mut t = envelope.body(op).text().to_string(); let links: Vec<Link> = finder.links(&t).collect(); if let Some(u) = links.get(lidx) { u.as_str().to_string() |