notedeck

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

scoped_sub_owner_keys.rs (1137B)


      1 use enostr::{NoteId, Pubkey};
      2 use notedeck::SubOwnerKey;
      3 
      4 use crate::timeline::TimelineKind;
      5 
      6 #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
      7 enum ColumnsOwner {
      8     OnboardingFollowPacks,
      9     ThreadScope,
     10     TimelineRemote,
     11 }
     12 
     13 /// Stable owner key for onboarding follow-pack scoped subscriptions.
     14 pub fn onboarding_owner_key(col: usize) -> SubOwnerKey {
     15     SubOwnerKey::builder(ColumnsOwner::OnboardingFollowPacks)
     16         .with(col)
     17         .finish()
     18 }
     19 
     20 /// Stable owner key for one thread scope within one column and account.
     21 pub fn thread_scope_owner_key(
     22     account_pk: Pubkey,
     23     col: usize,
     24     root_id: &NoteId,
     25     scope_depth: usize,
     26 ) -> SubOwnerKey {
     27     SubOwnerKey::builder(ColumnsOwner::ThreadScope)
     28         .with(account_pk)
     29         .with(col)
     30         .with(*root_id.bytes())
     31         .with(scope_depth)
     32         .finish()
     33 }
     34 
     35 /// Stable owner key for timeline remote subscriptions per account/kind pair.
     36 pub fn timeline_remote_owner_key(account_pk: Pubkey, kind: &TimelineKind) -> SubOwnerKey {
     37     SubOwnerKey::builder(ColumnsOwner::TimelineRemote)
     38         .with(account_pk)
     39         .with(kind)
     40         .finish()
     41 }