Browse Source

ui/sqlite3: add has:attachment query

tags/pre-alpha-0.4.0
Manos Pitsidianakis 2 years ago
parent
commit
c9c4e1ea60
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 10
      ui/src/cache.rs
  2. 3
      ui/src/sqlite3.rs

10
ui/src/cache.rs

@ -52,6 +52,7 @@ pub enum Query {
AllText(String),
/* * * * */
Flags(Vec<String>),
HasAttachment,
And(Box<Query>, Box<Query>),
Or(Box<Query>, Box<Query>),
Not(Box<Query>),
@ -127,6 +128,14 @@ pub mod query_parser {
}
}
fn has_attachment<'a>() -> impl Parser<'a, Query> {
move |input| {
whitespace_wrap(match_literal_anycase("has:attachment"))
.map(|()| Query::HasAttachment)
.parse(input)
}
}
fn literal<'a>() -> impl Parser<'a, String> {
move |input| either(quoted_string(), string()).parse(input)
}
@ -196,6 +205,7 @@ pub mod query_parser {
.or(bcc().parse(input))
.or(subject().parse(input))
.or(flags().parse(input))
.or(has_attachment().parse(input))
{
Ok(q)
} else if let Ok((rest, query_a)) = not().parse(input) {

3
ui/src/sqlite3.rs

@ -461,6 +461,9 @@ pub fn query_to_sql(q: &Query) -> String {
s.push_str(") ");
}
}
HasAttachment => {
s.push_str("has_attachments == 1 ");
}
_ => {}
}
}

Loading…
Cancel
Save