ui: small configuration fixes
- unused options were removed, - renamed `index` conf option to `index_style`embed
parent
e6b7d3a855
commit
8795c2da4f
|
@ -25,7 +25,6 @@ pub struct AccountSettings {
|
|||
pub name: String,
|
||||
pub root_folder: String,
|
||||
pub format: String,
|
||||
pub sent_folder: String,
|
||||
pub identity: String,
|
||||
pub read_only: bool,
|
||||
pub display_name: Option<String>,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue