diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-04-10 18:57:09 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:44 +0300 |
commit | 42a512d01084691c67cb074f9863cfd1e50ad978 (patch) | |
tree | fc72a6c6463afc4b973420ec946ef38eae38e963 | |
parent | 8149f5712f735f129647369a5acfb506848b8857 (diff) |
ui: save sent messages to Sent folder
-rw-r--r-- | ui/src/components/mail/compose.rs | 21 | ||||
-rw-r--r-- | ui/src/conf.rs | 3 | ||||
-rw-r--r-- | ui/src/conf/accounts.rs | 3 |
3 files changed, 26 insertions, 1 deletions
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 88023783..d38f1355 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -258,7 +258,8 @@ impl Component for Composer { }; if !self.initialized { - if !self.draft.headers().contains_key("From") { + if !self.draft.headers().contains_key("From") || self.draft.headers()["From"].is_empty() + { self.draft.headers_mut().insert( "From".into(), get_display_name(context, self.account_cursor), @@ -555,6 +556,24 @@ impl Component for Composer { stdin .write_all(draft.as_bytes()) .expect("Failed to write to stdin"); + if let Err(e) = context.accounts[self.account_cursor].save( + draft.as_bytes(), + &context.accounts[self.account_cursor] + .settings + .conf() + .sent_folder(), + ) { + if cfg!(feature = "debug_log") { + eprintln!("{:?} could not save sent msg", e); + } + context.replies.push_back(UIEvent { + id: 0, + event_type: UIEventType::Notification( + Some("Could not save in 'Sent' folder.".into()), + e.into(), + ), + }); + } } context.replies.push_back(UIEvent { id: 0, diff --git a/ui/src/conf.rs b/ui/src/conf.rs index 58bed642..7b2e1673 100644 --- a/ui/src/conf.rs +++ b/ui/src/conf.rs @@ -122,6 +122,9 @@ impl FileAccount { pub fn index(&self) -> IndexStyle { self.index } + pub fn sent_folder(&self) -> &str { + self.sent_folder.as_str() + } pub fn html_filter(&self) -> Option<&str> { self.html_filter.as_ref().map(|f| f.as_str()) } diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index 05bf8997..dfa8ac38 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -351,6 +351,9 @@ impl Account { self.backend .save(&finalize.as_bytes(), &self.settings.conf.draft_folder) } + pub fn save(&self, bytes: &[u8], folder: &str) -> Result<()> { + self.backend.save(bytes, folder) + } pub fn iter_mailboxes<'a>(&'a self) -> MailboxIterator<'a> { MailboxIterator { folders: &self.folders, |