notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit c34227b5f7bf95617d7f44388c05183284a30c19
parent 4fdbad0df82fa6a1942422423066995f021997f4
Author: William Casarin <jb55@jb55.com>
Date:   Tue,  3 Sep 2024 11:12:02 -0700

arg: add -c profile{,:pubkey} arg column

This allows you to add profile columns

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/args.rs | 15+++++++++++++++
Msrc/column.rs | 27++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/args.rs b/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; diff --git a/src/column.rs b/src/column.rs @@ -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?,