diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-11-24 10:34:28 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-11-24 10:36:31 +0200 |
commit | b46cd09ca6abee4603d22373bff4c34148bc222f (patch) | |
tree | ac5518c8489f1c9c98e6ff6cdef40142894a80c3 /src | |
parent | bf56c88918d42d6d1c33c0deb7df0ca32b4956e1 (diff) |
compose: pass body text when replying
Get rendered body text when creating a new reply Composer instead of
rendering the text in the Composer constructor.
Closes #86
Diffstat (limited to 'src')
-rw-r--r-- | src/components/mail/compose.rs | 17 | ||||
-rw-r--r-- | src/components/mail/view.rs | 30 |
2 files changed, 26 insertions, 21 deletions
diff --git a/src/components/mail/compose.rs b/src/components/mail/compose.rs index f3b88eae..5a2fa404 100644 --- a/src/components/mail/compose.rs +++ b/src/components/mail/compose.rs @@ -212,7 +212,7 @@ impl Composer { pub fn reply_to( coordinates: (AccountHash, MailboxHash, EnvelopeHash), - bytes: &[u8], + reply_body: String, context: &mut Context, reply_to_all: bool, ) -> Self { @@ -313,10 +313,7 @@ impl Composer { ret.draft.set_header("To", envelope.field_from_to_string()); } } - let body = envelope.body_bytes(bytes); ret.draft.body = { - let reply_body_bytes = decode_rec(&body, None); - let reply_body = String::from_utf8_lossy(&reply_body_bytes); let mut ret = format!( "On {} {} wrote:\n", envelope.date_as_str(), @@ -337,10 +334,10 @@ impl Composer { pub fn reply_to_select( coordinates: (AccountHash, MailboxHash, EnvelopeHash), - bytes: &[u8], + reply_body: String, context: &mut Context, ) -> Self { - let mut ret = Composer::reply_to(coordinates, bytes, context, false); + let mut ret = Composer::reply_to(coordinates, reply_body, context, false); let account = &context.accounts[&coordinates.0]; let parent_message = account.collection.get_env(coordinates.2); /* If message is from a mailing list and we detect a List-Post header, ask user if they @@ -385,18 +382,18 @@ impl Composer { pub fn reply_to_author( coordinates: (AccountHash, MailboxHash, EnvelopeHash), - bytes: &[u8], + reply_body: String, context: &mut Context, ) -> Self { - Composer::reply_to(coordinates, bytes, context, false) + Composer::reply_to(coordinates, reply_body, context, false) } pub fn reply_to_all( coordinates: (AccountHash, MailboxHash, EnvelopeHash), - bytes: &[u8], + reply_body: String, context: &mut Context, ) -> Self { - Composer::reply_to(coordinates, bytes, context, true) + Composer::reply_to(coordinates, reply_body, context, true) } pub fn set_draft(&mut self, draft: Draft) { diff --git a/src/components/mail/view.rs b/src/components/mail/view.rs index 14514216..ab8a57f5 100644 --- a/src/components/mail/view.rs +++ b/src/components/mail/view.rs @@ -382,7 +382,7 @@ impl MailView { } fn perform_action(&mut self, action: PendingReplyAction, context: &mut Context) { - let bytes = match self.state { + let reply_body = match self.state { MailViewState::Init { ref mut pending_action, .. @@ -396,21 +396,29 @@ impl MailView { } return; } - MailViewState::Loaded { ref bytes, .. } => bytes, + MailViewState::Loaded { ref display, .. } => { + self.attachment_displays_to_text(&display, context, false) + } MailViewState::Error { .. } => { return; } }; let composer = match action { - PendingReplyAction::Reply => { - Box::new(Composer::reply_to_select(self.coordinates, bytes, context)) - } - PendingReplyAction::ReplyToAuthor => { - Box::new(Composer::reply_to_author(self.coordinates, bytes, context)) - } - PendingReplyAction::ReplyToAll => { - Box::new(Composer::reply_to_all(self.coordinates, bytes, context)) - } + PendingReplyAction::Reply => Box::new(Composer::reply_to_select( + self.coordinates, + reply_body, + context, + )), + PendingReplyAction::ReplyToAuthor => Box::new(Composer::reply_to_author( + self.coordinates, + reply_body, + context, + )), + PendingReplyAction::ReplyToAll => Box::new(Composer::reply_to_all( + self.coordinates, + reply_body, + context, + )), }; context |