mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
make pagination starting at 1 instead of 0 (#186)
This commit is contained in:
parent
97054d3133
commit
52e76d19e5
|
@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Config option `signature-delimiter` to customize the signature delimiter (default to `-- \n`) [[#114](https://github.com/soywod/himalaya/pull/114)]
|
||||
- Expand tilde and env vars for `downloads-dir` and `signature` [#102]
|
||||
|
||||
### Changed
|
||||
|
||||
- Pagination for list and search cmd starts from 1 instead of 0 [#186]
|
||||
|
||||
### Fixed
|
||||
|
||||
- New/reply/forward from Vim plugin since Tpl refactor [#176]
|
||||
|
@ -307,3 +311,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#146]: https://github.com/soywod/himalaya/issues/146
|
||||
[#160]: https://github.com/soywod/himalaya/issues/160
|
||||
[#176]: https://github.com/soywod/himalaya/issues/176
|
||||
[#186]: https://github.com/soywod/himalaya/issues/186
|
||||
|
|
|
@ -66,7 +66,7 @@ fn page_arg<'a>() -> clap::Arg<'a, 'a> {
|
|||
.short("p")
|
||||
.long("page")
|
||||
.value_name("INT")
|
||||
.default_value("0")
|
||||
.default_value("1")
|
||||
}
|
||||
|
||||
fn attachment_arg<'a>() -> clap::Arg<'a, 'a> {
|
||||
|
@ -185,6 +185,7 @@ fn msg_matches_list(ctx: &Ctx, opt_matches: Option<&clap::ArgMatches>) -> Result
|
|||
debug!("page size: {:?}", page_size);
|
||||
let page: usize = opt_matches
|
||||
.and_then(|matches| matches.value_of("page").unwrap().parse().ok())
|
||||
.map(|page| 1.max(page) - 1)
|
||||
.unwrap_or_default();
|
||||
debug!("page: {}", &page);
|
||||
|
||||
|
@ -215,7 +216,8 @@ fn msg_matches_search(ctx: &Ctx, matches: &clap::ArgMatches) -> Result<bool> {
|
|||
.value_of("page")
|
||||
.unwrap()
|
||||
.parse()
|
||||
.unwrap_or_default();
|
||||
.map(|page| 1.max(page) - 1)
|
||||
.unwrap_or(1);
|
||||
debug!("page: {}", &page);
|
||||
|
||||
let query = matches
|
||||
|
|
|
@ -74,7 +74,7 @@ fn msg() {
|
|||
|
||||
// List messages
|
||||
// TODO: check non-existance of \Seen flag
|
||||
let msgs = imap_conn.list_msgs("INBOX", &10, &0).unwrap();
|
||||
let msgs = imap_conn.list_msgs("INBOX", &10, &1).unwrap();
|
||||
let msgs = if let Some(ref fetches) = msgs {
|
||||
Msgs::from(fetches)
|
||||
} else {
|
||||
|
@ -111,7 +111,7 @@ fn msg() {
|
|||
.add_flags("INBOX", &msg_b.uid.to_string(), "\\Deleted")
|
||||
.unwrap();
|
||||
imap_conn.expunge("INBOX").unwrap();
|
||||
assert!(imap_conn.list_msgs("INBOX", &10, &0).unwrap().is_none());
|
||||
assert!(imap_conn.list_msgs("INBOX", &10, &1).unwrap().is_none());
|
||||
|
||||
// Logout
|
||||
imap_conn.logout();
|
||||
|
|
Loading…
Reference in a new issue