nip10: switch to NoteReply instead of handrolled logic
Cc: kernelkind Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -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",
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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;
|
||||
.custom(move |note: nostrdb::Note<'_>| {
|
||||
let reply = nostrdb::NoteReply::new(note.tags());
|
||||
if reply.is_reply_to_root() {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user