mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 21:37:55 +08:00
add default page size config (#96)
This commit is contained in:
@@ -8,6 +8,8 @@ use crate::output::utils::run_cmd;
|
||||
|
||||
error_chain! {}
|
||||
|
||||
const DEFAULT_PAGE_SIZE: usize = 10;
|
||||
|
||||
// Account
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -17,6 +19,7 @@ pub struct Account {
|
||||
pub name: Option<String>,
|
||||
pub downloads_dir: Option<PathBuf>,
|
||||
pub signature: Option<String>,
|
||||
pub default_page_size: Option<usize>,
|
||||
|
||||
// Specific
|
||||
pub default: Option<bool>,
|
||||
@@ -94,6 +97,7 @@ pub struct Config {
|
||||
pub downloads_dir: Option<PathBuf>,
|
||||
pub notify_cmd: Option<String>,
|
||||
pub signature: Option<String>,
|
||||
pub default_page_size: Option<usize>,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub accounts: HashMap<String, Account>,
|
||||
@@ -193,4 +197,14 @@ impl Config {
|
||||
.or_else(|| self.signature.as_ref())
|
||||
.map(|sig| sig.to_owned())
|
||||
}
|
||||
|
||||
pub fn default_page_size(&self, account: &Account) -> usize {
|
||||
account
|
||||
.default_page_size
|
||||
.as_ref()
|
||||
.or_else(|| self.default_page_size.as_ref())
|
||||
.or(Some(&DEFAULT_PAGE_SIZE))
|
||||
.unwrap()
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user