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
|
||||
.push(ArgColumn::Timeline(TimelineKind::contact_list(
|
||||
deck_author.to_owned(),
|
||||
)))
|
||||
)));
|
||||
} 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:") {
|
||||
if let Ok(pubkey) = Pubkey::parse(notif_pk_str) {
|
||||
info!("got notifications column for user {}", pubkey.hex());
|
||||
res.columns
|
||||
.push(ArgColumn::Timeline(TimelineKind::notifications(pubkey)))
|
||||
.push(ArgColumn::Timeline(TimelineKind::notifications(pubkey)));
|
||||
} else {
|
||||
error!("error parsing notifications pubkey {}", notif_pk_str);
|
||||
continue;
|
||||
|
||||
@@ -24,6 +24,10 @@ impl TokenSerializable for 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
|
||||
fn to_msgpack_value(&self) -> Value {
|
||||
let mut values: Vec<(Value, Value)> = Vec::with_capacity(2);
|
||||
|
||||
@@ -406,6 +406,10 @@ impl TimelineKind {
|
||||
TimelineKind::List(ListKind::contact_list(pk))
|
||||
}
|
||||
|
||||
pub fn search(s: String) -> Self {
|
||||
TimelineKind::Search(SearchQuery::new(s))
|
||||
}
|
||||
|
||||
pub fn is_contacts(&self) -> bool {
|
||||
matches!(self, TimelineKind::List(ListKind::Contact(_)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user