diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-03-29 19:37:02 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:41 +0300 |
commit | d19bda89776346b72c8e5dd36880a94f58299cec (patch) | |
tree | c9410971f4b29bbcc9031ca5b539635d81fa3838 /ui | |
parent | 1aa4eaa3142661ceb5df871fd0361abf289682a0 (diff) |
melib: properly save drafts in maildir backend
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/mail/compose.rs | 14 | ||||
-rw-r--r-- | ui/src/conf/accounts.rs | 3 |
2 files changed, 10 insertions, 7 deletions
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 532fa282..5ec25443 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -487,13 +487,15 @@ impl Component for Composer { ('y', ViewMode::Discard(u)) => { let account = &context.accounts[self.account_cursor]; let draft = std::mem::replace(&mut self.draft, Draft::default()); - if cfg!(feature = "debug_log") { - eprintln!("{:?}", account.save_draft(draft)); + if let Err(e) = account.save_draft(draft) { + if cfg!(feature = "debug_log") { + eprintln!("{:?} could not save draft", e); + } + context.replies.push_back(UIEvent { + id: 0, + event_type: UIEventType::Notification(Some("Could not save draft.".into()), e.into()) + }); } - - //if cfg!(feature = "debug_log") { - //eprintln!("{:?}", self.draft.to_string()); - //} context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::Action(Tab(Kill(*u))), diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index 7cc9fbf7..e32d2492 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -302,8 +302,9 @@ impl Account { } pub fn save_draft(&self, draft: Draft) -> Result<()> { + let finalize = draft.finalise()?; self.backend - .save(draft.to_string()?, &self.settings.conf.draft_folder) + .save(&finalize.as_bytes(), &self.settings.conf.draft_folder) } } |