mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 18:45:13 +00:00
add missing flags column for msgs table
This commit is contained in:
parent
1e5cce0205
commit
c9b26031e2
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- IDLE support [#29]
|
- IDLE support [#29]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Errors management with `error_chain` [#39]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Missing `FLAGS` column in messages table [#40]
|
||||||
|
|
||||||
## [0.2.0] - 2021-03-10
|
## [0.2.0] - 2021-03-10
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -72,3 +80,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
[#25]: https://github.com/soywod/himalaya/issues/25
|
[#25]: https://github.com/soywod/himalaya/issues/25
|
||||||
[#29]: https://github.com/soywod/himalaya/issues/29
|
[#29]: https://github.com/soywod/himalaya/issues/29
|
||||||
[#32]: https://github.com/soywod/himalaya/issues/32
|
[#32]: https://github.com/soywod/himalaya/issues/32
|
||||||
|
[#39]: https://github.com/soywod/himalaya/issues/39
|
||||||
|
[#40]: https://github.com/soywod/himalaya/issues/40
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl<'a> ImapConnector<'a> {
|
||||||
|
|
||||||
let msgs = self
|
let msgs = self
|
||||||
.sess
|
.sess
|
||||||
.fetch(&range, "(UID ENVELOPE INTERNALDATE)")
|
.fetch(&range, "(UID FLAGS ENVELOPE INTERNALDATE)")
|
||||||
.chain_err(|| format!("Cannot fetch range `{}`", &range))?
|
.chain_err(|| format!("Cannot fetch range `{}`", &range))?
|
||||||
.iter()
|
.iter()
|
||||||
.map(Msg::from)
|
.map(Msg::from)
|
||||||
|
|
|
@ -58,6 +58,6 @@ impl<'a> DisplayTable<'a, Mbox> for Mboxes {
|
||||||
|
|
||||||
impl fmt::Display for Mboxes {
|
impl fmt::Display for Mboxes {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", self.to_table())
|
write!(f, "\n{}", self.to_table())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
46
src/msg.rs
46
src/msg.rs
|
@ -170,7 +170,7 @@ impl<'a> ReadableMsg {
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Flag {
|
pub enum Flag {
|
||||||
Seen,
|
Seen,
|
||||||
|
@ -252,6 +252,30 @@ impl From<&imap::types::Fetch> for Msg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Msg {
|
impl<'a> Msg {
|
||||||
|
pub fn display_flags(&self) -> String {
|
||||||
|
let mut flags = String::new();
|
||||||
|
|
||||||
|
flags.push_str(if self.flags.contains(&Flag::Seen) {
|
||||||
|
" "
|
||||||
|
} else {
|
||||||
|
"✶"
|
||||||
|
});
|
||||||
|
|
||||||
|
flags.push_str(if self.flags.contains(&Flag::Answered) {
|
||||||
|
"↩"
|
||||||
|
} else {
|
||||||
|
" "
|
||||||
|
});
|
||||||
|
|
||||||
|
flags.push_str(if self.flags.contains(&Flag::Flagged) {
|
||||||
|
"!"
|
||||||
|
} else {
|
||||||
|
" "
|
||||||
|
});
|
||||||
|
|
||||||
|
flags
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse(&'a self) -> Result<mailparse::ParsedMail<'a>> {
|
pub fn parse(&'a self) -> Result<mailparse::ParsedMail<'a>> {
|
||||||
Ok(mailparse::parse_mail(&self.raw)?)
|
Ok(mailparse::parse_mail(&self.raw)?)
|
||||||
}
|
}
|
||||||
|
@ -529,11 +553,18 @@ impl DisplayRow for Msg {
|
||||||
fn to_row(&self) -> Vec<table::Cell> {
|
fn to_row(&self) -> Vec<table::Cell> {
|
||||||
use crate::table::*;
|
use crate::table::*;
|
||||||
|
|
||||||
|
let unseen = if self.flags.contains(&Flag::Seen) {
|
||||||
|
RESET
|
||||||
|
} else {
|
||||||
|
BOLD
|
||||||
|
};
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
Cell::new(&[RED], &self.uid.to_string()),
|
Cell::new(&[unseen.to_owned(), RED], &self.uid.to_string()),
|
||||||
Cell::new(&[BLUE], &self.sender),
|
Cell::new(&[unseen.to_owned(), WHITE], &self.display_flags()),
|
||||||
FlexCell::new(&[GREEN], &self.subject),
|
FlexCell::new(&[unseen.to_owned(), GREEN], &self.subject),
|
||||||
Cell::new(&[YELLOW], &self.date),
|
Cell::new(&[unseen.to_owned(), BLUE], &self.sender),
|
||||||
|
Cell::new(&[unseen.to_owned(), YELLOW], &self.date),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,8 +580,9 @@ impl<'a> DisplayTable<'a, Msg> for Msgs {
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
Cell::new(&[BOLD, UNDERLINE, WHITE], "UID"),
|
Cell::new(&[BOLD, UNDERLINE, WHITE], "UID"),
|
||||||
Cell::new(&[BOLD, UNDERLINE, WHITE], "SENDER"),
|
Cell::new(&[BOLD, UNDERLINE, WHITE], "FLAGS"),
|
||||||
FlexCell::new(&[BOLD, UNDERLINE, WHITE], "SUBJECT"),
|
FlexCell::new(&[BOLD, UNDERLINE, WHITE], "SUBJECT"),
|
||||||
|
Cell::new(&[BOLD, UNDERLINE, WHITE], "SENDER"),
|
||||||
Cell::new(&[BOLD, UNDERLINE, WHITE], "DATE"),
|
Cell::new(&[BOLD, UNDERLINE, WHITE], "DATE"),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -562,6 +594,6 @@ impl<'a> DisplayTable<'a, Msg> for Msgs {
|
||||||
|
|
||||||
impl fmt::Display for Msgs {
|
impl fmt::Display for Msgs {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", self.to_table())
|
write!(f, "\n{}", self.to_table())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue