mirror of
https://github.com/damus-io/notedeck.git
synced 2024-09-16 20:03:28 +00:00
arg: add -c profile{,:pubkey} arg column
This allows you to add profile columns Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
4fdbad0df8
commit
c34227b5f7
15
src/args.rs
15
src/args.rs
@ -150,6 +150,21 @@ impl Args {
|
||||
.push(ArgColumn::Column(ColumnKind::notifications(
|
||||
PubkeySource::DeckAuthor,
|
||||
)))
|
||||
} else if column_name == "profile" {
|
||||
debug!("got profile column for default user");
|
||||
res.columns.push(ArgColumn::Column(ColumnKind::profile(
|
||||
PubkeySource::DeckAuthor,
|
||||
)))
|
||||
} else if let Some(profile_pk_str) = column_name.strip_prefix("profile:") {
|
||||
if let Ok(pubkey) = Pubkey::parse(profile_pk_str) {
|
||||
info!("got profile column for user {}", pubkey.hex());
|
||||
res.columns.push(ArgColumn::Column(ColumnKind::profile(
|
||||
PubkeySource::Explicit(pubkey),
|
||||
)))
|
||||
} else {
|
||||
error!("error parsing profile pubkey {}", profile_pk_str);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if arg == "--filter-file" || arg == "-f" {
|
||||
i += 1;
|
||||
|
@ -25,12 +25,14 @@ pub enum ListKind {
|
||||
/// - DM
|
||||
/// - filter
|
||||
/// - ... etc
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ColumnKind {
|
||||
List(ListKind),
|
||||
|
||||
Notifications(PubkeySource),
|
||||
|
||||
Profile(PubkeySource),
|
||||
|
||||
Universe,
|
||||
|
||||
/// Generic filter
|
||||
@ -43,6 +45,7 @@ impl Display for ColumnKind {
|
||||
ColumnKind::List(ListKind::Contact(_src)) => f.write_str("Contacts"),
|
||||
ColumnKind::Generic => f.write_str("Timeline"),
|
||||
ColumnKind::Notifications(_) => f.write_str("Notifications"),
|
||||
ColumnKind::Profile(_) => f.write_str("Profile"),
|
||||
ColumnKind::Universe => f.write_str("Universe"),
|
||||
}
|
||||
}
|
||||
@ -53,6 +56,10 @@ impl ColumnKind {
|
||||
ColumnKind::List(ListKind::Contact(pk))
|
||||
}
|
||||
|
||||
pub fn profile(pk: PubkeySource) -> Self {
|
||||
ColumnKind::Profile(pk)
|
||||
}
|
||||
|
||||
pub fn notifications(pk: PubkeySource) -> Self {
|
||||
ColumnKind::Notifications(pk)
|
||||
}
|
||||
@ -69,6 +76,24 @@ impl ColumnKind {
|
||||
None
|
||||
}
|
||||
|
||||
ColumnKind::Profile(pk_src) => {
|
||||
let pk = match &pk_src {
|
||||
PubkeySource::DeckAuthor => default_user?,
|
||||
PubkeySource::Explicit(pk) => pk.bytes(),
|
||||
};
|
||||
|
||||
let filter = Filter::new()
|
||||
.authors([pk])
|
||||
.kinds([1])
|
||||
.limit(filter::default_limit())
|
||||
.build();
|
||||
|
||||
Some(Timeline::new(
|
||||
ColumnKind::profile(pk_src),
|
||||
FilterState::ready(vec![filter]),
|
||||
))
|
||||
}
|
||||
|
||||
ColumnKind::Notifications(pk_src) => {
|
||||
let pk = match &pk_src {
|
||||
PubkeySource::DeckAuthor => default_user?,
|
||||
|
Loading…
Reference in New Issue
Block a user