diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-16 14:09:08 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-16 16:41:22 +0300 |
commit | 8795c2da4f1b082b17c0291aeecd2e51f4f4a51f (patch) | |
tree | 0015939983a5fc7bb60b98dc67984871346ff010 /ui | |
parent | e6b7d3a85567b6e747b6201c0be98e22715d7c68 (diff) |
ui: small configuration fixes
- unused options were removed,
- renamed `index` conf option to `index_style`
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/mail/compose.rs | 5 | ||||
-rw-r--r-- | ui/src/components/mail/listing.rs | 11 | ||||
-rw-r--r-- | ui/src/conf.rs | 18 | ||||
-rw-r--r-- | ui/src/conf/accounts.rs | 29 |
4 files changed, 41 insertions, 22 deletions
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 2a369751..699b0b90 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -775,10 +775,7 @@ pub fn send_draft(context: &mut Context, account_cursor: usize, draft: Draft) -> .expect("Failed to write to stdin"); if let Err(e) = context.accounts[account_cursor].save( draft.as_bytes(), - &context.accounts[account_cursor] - .settings - .conf() - .sent_folder(), + &context.accounts[account_cursor].sent_folder(), Some(Flag::SEEN), ) { debug!("{:?} could not save sent msg", e); diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index 2feb7259..9518a4e2 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -287,7 +287,7 @@ impl Component for Listing { if let Some(index_style) = context .accounts .get(self.cursor_pos.0) - .and_then(|account| account.folder_confs(folder_hash).conf_override.index) + .and_then(|account| account.folder_confs(folder_hash).conf_override.index_style) { self.component.set_style(index_style); }; @@ -332,7 +332,7 @@ impl Component for Listing { if let Some(index_style) = context .accounts .get(self.cursor_pos.0) - .and_then(|account| account.folder_confs(folder_hash).conf_override.index) + .and_then(|account| account.folder_confs(folder_hash).conf_override.index_style) { self.component.set_style(index_style); }; @@ -572,10 +572,9 @@ impl Listing { .collect(); /* Check if per-folder configuration overrides general configuration */ let component = if let Some(index_style) = accounts.get(0).and_then(|account| { - account - .folders_order - .get(0) - .and_then(|folder_hash| account.folder_confs(*folder_hash).conf_override.index) + account.folders_order.get(0).and_then(|folder_hash| { + account.folder_confs(*folder_hash).conf_override.index_style + }) }) { ListingComponent::from(index_style) } else { diff --git a/ui/src/conf.rs b/ui/src/conf.rs index 218f1458..223c737f 100644 --- a/ui/src/conf.rs +++ b/ui/src/conf.rs @@ -96,7 +96,7 @@ pub struct MailUIConf { pub shortcuts: Option<Shortcuts>, pub mailer: Option<MailerSettings>, pub identity: Option<String>, - pub index: Option<IndexStyle>, + pub index_style: Option<IndexStyle>, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -137,15 +137,13 @@ impl FolderConf { pub struct FileAccount { root_folder: String, format: String, - sent_folder: String, - draft_folder: String, identity: String, #[serde(flatten)] pub extra: HashMap<String, String>, #[serde(default = "none")] display_name: Option<String>, - index: IndexStyle, + index_style: IndexStyle, /// A command to pipe html output before displaying it in a pager /// Default: None @@ -161,7 +159,6 @@ pub struct FileAccount { impl From<FileAccount> for AccountConf { fn from(x: FileAccount) -> Self { let format = x.format.to_lowercase(); - let sent_folder = x.sent_folder.clone(); let root_folder = x.root_folder.clone(); let identity = x.identity.clone(); let display_name = x.display_name.clone(); @@ -170,7 +167,6 @@ impl From<FileAccount> for AccountConf { name: String::new(), root_folder, format, - sent_folder, identity, read_only: x.read_only, display_name, @@ -252,15 +248,15 @@ impl FileAccount { pub fn folders(&self) -> Option<&HashMap<String, FolderConf>> { self.folders.as_ref() } + pub fn folder(&self) -> &str { &self.root_folder } - pub fn index(&self) -> IndexStyle { - self.index - } - pub fn sent_folder(&self) -> &str { - self.sent_folder.as_str() + + pub fn index_style(&self) -> IndexStyle { + self.index_style } + pub fn html_filter(&self) -> Option<&str> { self.html_filter.as_ref().map(String::as_str) } diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index dd4c5a3f..eb33a9bc 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -650,9 +650,23 @@ impl Account { self.name.as_str() ))); } + let draft_folder = self + .settings + .folder_confs + .iter() + .find(|(_, f)| f.usage == Some(SpecialUseMailbox::Drafts)); + if draft_folder.is_none() { + return Err(MeliError::new(format!( + "Account {} has no draft folder set.", + self.name.as_str() + ))); + } + + let draft_folder = draft_folder.unwrap(); + let finalize = draft.finalise()?; self.backend - .save(&finalize.as_bytes(), &self.settings.conf.draft_folder, None) + .save(&finalize.as_bytes(), draft_folder.0, None) } pub fn save(&self, bytes: &[u8], folder: &str, flags: Option<Flag>) -> Result<()> { if self.settings.account.read_only() { @@ -736,6 +750,19 @@ impl Account { pub fn folder_confs(&self, folder_hash: FolderHash) -> &FolderConf { &self.folder_confs[&folder_hash] } + + pub fn sent_folder(&self) -> &str { + let sent_folder = self + .settings + .folder_confs + .iter() + .find(|(_, f)| f.usage == Some(SpecialUseMailbox::Sent)); + if let Some(sent_folder) = sent_folder.as_ref() { + sent_folder.0 + } else { + "" + } + } } impl Index<FolderHash> for Account { |