notedeck

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

commit 469868dd536291653f86b6bf187aadcd3146cefe
parent 41fdf47b47682635940e4a5b0cc677b373598747
Author: kernelkind <kernelkind@gmail.com>
Date:   Tue, 16 Dec 2025 17:55:10 -0500

feat(note): helper to get all p tags from note

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/lib.rs | 4++--
Mcrates/notedeck/src/note/mod.rs | 21+++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs @@ -71,8 +71,8 @@ pub use name::NostrName; pub use nav::DragResponse; pub use nip51_set::{create_nip51_set, Nip51Set, Nip51SetCache}; pub use note::{ - BroadcastContext, ContextSelection, NoteAction, NoteContext, NoteContextSelection, NoteRef, - RootIdError, RootNoteId, RootNoteIdBuf, ScrollInfo, ZapAction, + get_p_tags, BroadcastContext, ContextSelection, NoteAction, NoteContext, NoteContextSelection, + NoteRef, RootIdError, RootNoteId, RootNoteIdBuf, ScrollInfo, ZapAction, }; pub use notecache::{CachedNote, NoteCache}; pub use options::NotedeckOptions; diff --git a/crates/notedeck/src/note/mod.rs b/crates/notedeck/src/note/mod.rs @@ -239,3 +239,24 @@ pub fn count_hashtags(note: &Note) -> usize { count } + +pub fn get_p_tags<'a>(note: &Note<'a>) -> Vec<&'a [u8; 32]> { + let mut items = Vec::new(); + for tag in note.tags() { + if tag.count() < 2 { + continue; + } + + if tag.get_str(0) != Some("p") { + continue; + } + + let Some(item) = tag.get_id(1) else { + continue; + }; + + items.push(item); + } + + items +}