args: add search column argument
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -73,15 +73,27 @@ impl ColumnsArgs {
|
|||||||
res.columns
|
res.columns
|
||||||
.push(ArgColumn::Timeline(TimelineKind::contact_list(
|
.push(ArgColumn::Timeline(TimelineKind::contact_list(
|
||||||
deck_author.to_owned(),
|
deck_author.to_owned(),
|
||||||
)))
|
)));
|
||||||
} else {
|
} else {
|
||||||
panic!("No accounts available, could not handle implicit pubkey contacts column")
|
panic!("No accounts available, could not handle implicit pubkey contacts column");
|
||||||
}
|
}
|
||||||
|
} else if column_name == "search" {
|
||||||
|
i += 1;
|
||||||
|
let search = if let Some(next_arg) = args.get(i) {
|
||||||
|
next_arg
|
||||||
|
} else {
|
||||||
|
error!("search filter argument missing?");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
res.columns.push(ArgColumn::Timeline(TimelineKind::search(
|
||||||
|
search.to_string(),
|
||||||
|
)));
|
||||||
} else if let Some(notif_pk_str) = column_name.strip_prefix("notifications:") {
|
} else if let Some(notif_pk_str) = column_name.strip_prefix("notifications:") {
|
||||||
if let Ok(pubkey) = Pubkey::parse(notif_pk_str) {
|
if let Ok(pubkey) = Pubkey::parse(notif_pk_str) {
|
||||||
info!("got notifications column for user {}", pubkey.hex());
|
info!("got notifications column for user {}", pubkey.hex());
|
||||||
res.columns
|
res.columns
|
||||||
.push(ArgColumn::Timeline(TimelineKind::notifications(pubkey)))
|
.push(ArgColumn::Timeline(TimelineKind::notifications(pubkey)));
|
||||||
} else {
|
} else {
|
||||||
error!("error parsing notifications pubkey {}", notif_pk_str);
|
error!("error parsing notifications pubkey {}", notif_pk_str);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ impl TokenSerializable for SearchQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SearchQuery {
|
impl SearchQuery {
|
||||||
|
pub fn new(search: String) -> Self {
|
||||||
|
let author: Option<Pubkey> = None;
|
||||||
|
Self { search, author }
|
||||||
|
}
|
||||||
/// Convert the query to a filter-compatible MessagePack value
|
/// Convert the query to a filter-compatible MessagePack value
|
||||||
fn to_msgpack_value(&self) -> Value {
|
fn to_msgpack_value(&self) -> Value {
|
||||||
let mut values: Vec<(Value, Value)> = Vec::with_capacity(2);
|
let mut values: Vec<(Value, Value)> = Vec::with_capacity(2);
|
||||||
|
|||||||
@@ -406,6 +406,10 @@ impl TimelineKind {
|
|||||||
TimelineKind::List(ListKind::contact_list(pk))
|
TimelineKind::List(ListKind::contact_list(pk))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn search(s: String) -> Self {
|
||||||
|
TimelineKind::Search(SearchQuery::new(s))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_contacts(&self) -> bool {
|
pub fn is_contacts(&self) -> bool {
|
||||||
matches!(self, TimelineKind::List(ListKind::Contact(_)))
|
matches!(self, TimelineKind::List(ListKind::Contact(_)))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user