notedeck

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

commit 7a83483758f148d472cf2c769ff577429c8e97c2
parent 1a3112d8efdb5ca826239a38aa30b5ba4bbb63a3
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 24 Jul 2025 13:31:12 -0700

nip10: switch to NoteReply instead of handrolled logic

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

Diffstat:
MCargo.lock | 4++--
MCargo.toml | 2+-
Mcrates/notedeck_columns/src/timeline/thread.rs | 70+++++++++++-----------------------------------------------------------
3 files changed, 14 insertions(+), 62 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -3403,8 +3403,8 @@ dependencies = [ [[package]] name = "nostrdb" -version = "0.7.0" -source = "git+https://github.com/damus-io/nostrdb-rs?rev=a307f5d3863b5319c728b2782959839b8df544cb#a307f5d3863b5319c728b2782959839b8df544cb" +version = "0.8.0" +source = "git+https://github.com/damus-io/nostrdb-rs?rev=2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3#2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml @@ -42,7 +42,7 @@ md5 = "0.7.0" nostr = { version = "0.37.0", default-features = false, features = ["std", "nip49"] } nwc = "0.39.0" mio = { version = "1.0.3", features = ["os-poll", "net"] } -nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "a307f5d3863b5319c728b2782959839b8df544cb" } +nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3" } #nostrdb = "0.6.1" notedeck = { path = "crates/notedeck" } notedeck_chrome = { path = "crates/notedeck_chrome" } diff --git a/crates/notedeck_columns/src/timeline/thread.rs b/crates/notedeck_columns/src/timeline/thread.rs @@ -405,32 +405,13 @@ fn direct_replies_filter_non_root( let tmp_selected = *selected_note_id; nostrdb::Filter::new() .kinds([1]) - .custom(move |n: nostrdb::Note<'_>| { - for tag in n.tags() { - if tag.count() < 4 { - continue; - } - - let Some("e") = tag.get_str(0) else { - continue; - }; - - let Some(tagged_id) = tag.get_id(1) else { - continue; - }; - - if *tagged_id != tmp_selected { - // NOTE: if these aren't dereferenced a segfault occurs... - continue; - } - - if let Some(data) = tag.get_str(3) { - if data == "reply" { - return true; - } - } + .custom(move |note: nostrdb::Note<'_>| { + let reply = nostrdb::NoteReply::new(note.tags()); + if reply.is_reply_to_root() { + return false; } - false + + reply.reply().is_some_and(|r| r.id == &tmp_selected) }) .event(root_id) .build() @@ -448,42 +429,13 @@ fn direct_replies_filter_non_root( /// let tmp = *root_id; /// .custom(move |_| { tmp }) // ✅ fn direct_replies_filter_root(root_id: &[u8; 32]) -> nostrdb::Filter { - let tmp_root = *root_id; + let moved_root_id = *root_id; nostrdb::Filter::new() .kinds([1]) - .custom(move |n: nostrdb::Note<'_>| { - let mut contains_root = false; - for tag in n.tags() { - if tag.count() < 4 { - continue; - } - - let Some("e") = tag.get_str(0) else { - continue; - }; - - if let Some(s) = tag.get_str(3) { - if s == "reply" { - return false; - } - } - - let Some(tagged_id) = tag.get_id(1) else { - continue; - }; - - if *tagged_id != tmp_root { - continue; - } - - if let Some(s) = tag.get_str(3) { - if s == "root" { - contains_root = true; - } - } - } - - contains_root + .custom(move |note: nostrdb::Note<'_>| { + nostrdb::NoteReply::new(note.tags()) + .reply_to_root() + .is_some_and(|r| r.id == &moved_root_id) }) .event(root_id) .build()