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]]
|
[[package]]
|
||||||
name = "nostrdb"
|
name = "nostrdb"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "git+https://github.com/damus-io/nostrdb-rs?rev=a307f5d3863b5319c728b2782959839b8df544cb#a307f5d3863b5319c728b2782959839b8df544cb"
|
source = "git+https://github.com/damus-io/nostrdb-rs?rev=2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3#2b2e5e43c019b80b98f1db6a03a1b88ca699bfa3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ md5 = "0.7.0"
|
|||||||
nostr = { version = "0.37.0", default-features = false, features = ["std", "nip49"] }
|
nostr = { version = "0.37.0", default-features = false, features = ["std", "nip49"] }
|
||||||
nwc = "0.39.0"
|
nwc = "0.39.0"
|
||||||
mio = { version = "1.0.3", features = ["os-poll", "net"] }
|
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"
|
#nostrdb = "0.6.1"
|
||||||
notedeck = { path = "crates/notedeck" }
|
notedeck = { path = "crates/notedeck" }
|
||||||
notedeck_chrome = { path = "crates/notedeck_chrome" }
|
notedeck_chrome = { path = "crates/notedeck_chrome" }
|
||||||
|
|||||||
@@ -405,32 +405,13 @@ fn direct_replies_filter_non_root(
|
|||||||
let tmp_selected = *selected_note_id;
|
let tmp_selected = *selected_note_id;
|
||||||
nostrdb::Filter::new()
|
nostrdb::Filter::new()
|
||||||
.kinds([1])
|
.kinds([1])
|
||||||
.custom(move |n: nostrdb::Note<'_>| {
|
.custom(move |note: nostrdb::Note<'_>| {
|
||||||
for tag in n.tags() {
|
let reply = nostrdb::NoteReply::new(note.tags());
|
||||||
if tag.count() < 4 {
|
if reply.is_reply_to_root() {
|
||||||
continue;
|
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)
|
.event(root_id)
|
||||||
.build()
|
.build()
|
||||||
@@ -448,42 +429,13 @@ fn direct_replies_filter_non_root(
|
|||||||
/// let tmp = *root_id;
|
/// let tmp = *root_id;
|
||||||
/// .custom(move |_| { tmp }) // ✅
|
/// .custom(move |_| { tmp }) // ✅
|
||||||
fn direct_replies_filter_root(root_id: &[u8; 32]) -> nostrdb::Filter {
|
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()
|
nostrdb::Filter::new()
|
||||||
.kinds([1])
|
.kinds([1])
|
||||||
.custom(move |n: nostrdb::Note<'_>| {
|
.custom(move |note: nostrdb::Note<'_>| {
|
||||||
let mut contains_root = false;
|
nostrdb::NoteReply::new(note.tags())
|
||||||
for tag in n.tags() {
|
.reply_to_root()
|
||||||
if tag.count() < 4 {
|
.is_some_and(|r| r.id == &moved_root_id)
|
||||||
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
|
|
||||||
})
|
})
|
||||||
.event(root_id)
|
.event(root_id)
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
Reference in New Issue
Block a user