mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-16 20:57:53 +08:00
refactor new backend api
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
#[cfg(feature = "imap")]
|
||||
use email::folder::add::imap::AddImapFolder;
|
||||
#[cfg(feature = "maildir")]
|
||||
use email::folder::add::maildir::AddMaildirFolder;
|
||||
#[cfg(feature = "notmuch")]
|
||||
use email::folder::add::notmuch::AddNotmuchFolder;
|
||||
use log::info;
|
||||
|
||||
#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))]
|
||||
use crate::backend::BackendKind;
|
||||
#[cfg(feature = "account-sync")]
|
||||
use crate::cache::arg::disable::CacheDisableFlag;
|
||||
use crate::{
|
||||
@@ -48,36 +40,10 @@ impl AddFolderCommand {
|
||||
let add_folder_kind = toml_account_config.add_folder_kind();
|
||||
|
||||
let backend = Backend::new(
|
||||
&toml_account_config,
|
||||
&account_config,
|
||||
toml_account_config.clone(),
|
||||
account_config,
|
||||
add_folder_kind,
|
||||
|builder| match add_folder_kind {
|
||||
#[cfg(feature = "imap")]
|
||||
Some(BackendKind::Imap) => {
|
||||
builder.set_add_folder(|ctx| ctx.imap.as_ref().map(AddImapFolder::new_boxed));
|
||||
}
|
||||
#[cfg(feature = "maildir")]
|
||||
Some(BackendKind::Maildir) => {
|
||||
builder.set_add_folder(|ctx| {
|
||||
ctx.maildir.as_ref().map(AddMaildirFolder::new_boxed)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "account-sync")]
|
||||
Some(BackendKind::MaildirForSync) => {
|
||||
builder.set_add_folder(|ctx| {
|
||||
ctx.maildir_for_sync
|
||||
.as_ref()
|
||||
.map(AddMaildirFolder::new_boxed)
|
||||
});
|
||||
}
|
||||
#[cfg(feature = "notmuch")]
|
||||
Some(BackendKind::Notmuch) => {
|
||||
builder.set_add_folder(|ctx| {
|
||||
ctx.notmuch.as_ref().map(AddNotmuchFolder::new_boxed)
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
|builder| builder.set_add_folder(Some(None)),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user