summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/src/conf.rs32
-rw-r--r--ui/src/conf/accounts.rs17
2 files changed, 41 insertions, 8 deletions
diff --git a/ui/src/conf.rs b/ui/src/conf.rs
index 9812b869..a3d5c359 100644
--- a/ui/src/conf.rs
+++ b/ui/src/conf.rs
@@ -38,6 +38,7 @@ pub use self::shortcuts::*;
use self::default_vals::*;
use self::notifications::NotificationsSettings;
use crate::pager::PagerSettings;
+use melib::backends::SpecialUseMailbox;
use melib::conf::AccountSettings;
use melib::error::*;
@@ -97,6 +98,8 @@ pub struct FolderConf {
subscribe: ToggleFlag,
#[serde(deserialize_with = "toggleflag_de", default)]
ignore: ToggleFlag,
+ #[serde(default = "none")]
+ usage: Option<SpecialUseMailbox>,
}
impl Default for FolderConf {
@@ -106,6 +109,7 @@ impl Default for FolderConf {
autoload: true,
subscribe: ToggleFlag::Unset,
ignore: ToggleFlag::False,
+ usage: None,
}
}
}
@@ -188,6 +192,34 @@ impl From<FileAccount> for AccountConf {
}
folder_confs.get_mut(s).unwrap().subscribe = ToggleFlag::True;
}
+
+ if folder_confs[s].usage.is_none() {
+ let name = s.split('/').last().unwrap_or("");
+ folder_confs.get_mut(s).unwrap().usage = if name.eq_ignore_ascii_case("inbox") {
+ Some(SpecialUseMailbox::Inbox)
+ } else if name.eq_ignore_ascii_case("archive") {
+ Some(SpecialUseMailbox::Archive)
+ } else if name.eq_ignore_ascii_case("drafts") {
+ Some(SpecialUseMailbox::Drafts)
+ } else if name.eq_ignore_ascii_case("junk") {
+ Some(SpecialUseMailbox::Junk)
+ } else if name.eq_ignore_ascii_case("spam") {
+ Some(SpecialUseMailbox::Junk)
+ } else if name.eq_ignore_ascii_case("sent") {
+ Some(SpecialUseMailbox::Sent)
+ } else if name.eq_ignore_ascii_case("trash") {
+ Some(SpecialUseMailbox::Trash)
+ } else {
+ Some(SpecialUseMailbox::Normal)
+ };
+ }
+
+ if folder_confs[s].ignore.is_unset() {
+ use SpecialUseMailbox::*;
+ if [Junk, Sent, Trash].contains(&folder_confs[s].usage.as_ref().unwrap()) {
+ folder_confs.get_mut(s).unwrap().ignore = ToggleFlag::InternalVal(true);
+ }
+ }
}
AccountConf {
diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs
index fdb23320..63e08a1d 100644
--- a/ui/src/conf/accounts.rs
+++ b/ui/src/conf/accounts.rs
@@ -24,12 +24,11 @@
*/
use super::AccountConf;
-use super::ToggleFlag;
use fnv::FnvHashMap;
use melib::async_workers::{Async, AsyncBuilder, AsyncStatus};
use melib::backends::{
BackendOp, Backends, Folder, FolderHash, MailBackend, NotifyFn, ReadOnlyOp, RefreshEvent,
- RefreshEventConsumer, RefreshEventKind,
+ RefreshEventConsumer, RefreshEventKind, SpecialUseMailbox,
};
use melib::error::{MeliError, Result};
use melib::mailbox::*;
@@ -189,12 +188,7 @@ struct FolderNode {
}
impl Account {
- pub fn new(
- name: String,
- mut settings: AccountConf,
- map: &Backends,
- notify_fn: NotifyFn,
- ) -> Self {
+ pub fn new(name: String, settings: AccountConf, map: &Backends, notify_fn: NotifyFn) -> Self {
let mut backend = map.get(settings.account().format())(settings.account());
let mut ref_folders: FnvHashMap<FolderHash, Folder> = backend.folders();
let mut folders: FnvHashMap<FolderHash, MailboxEntry> =
@@ -212,6 +206,13 @@ impl Account {
/* Skip unsubscribed folder */
continue;
}
+
+ match settings.folder_confs[f.path()].usage {
+ Some(SpecialUseMailbox::Sent) => {
+ sent_folder = Some(f.hash());
+ }
+ _ => {}
+ }
folder_names.insert(f.hash(), f.path().to_string());
}