ndb: switch to nostrdb notes

This is a refactor of the codebase to use a more memory-efficient
representation of notes. It should also be much faster at decoding since
we're using a custom C json parser now.

Changelog-Changed: Improved memory usage and performance when processing events
This commit is contained in:
William Casarin
2023-07-26 08:46:44 -07:00
parent 55bbe8f855
commit cebd1f48ca
110 changed files with 2153 additions and 1799 deletions

View File

@@ -13,15 +13,12 @@ struct MutelistView: View {
func RemoveAction(pubkey: Pubkey) -> some View {
Button {
guard let mutelist = damus_state.contacts.mutelist else {
return
}
guard let keypair = damus_state.keypair.to_full() else {
return
}
guard let new_ev = remove_from_mutelist(keypair: keypair, prev: mutelist, to_remove: pubkey) else {
guard let mutelist = damus_state.contacts.mutelist,
let keypair = damus_state.keypair.to_full(),
let new_ev = remove_from_mutelist(keypair: keypair,
prev: mutelist,
to_remove: .pubkey(pubkey))
else {
return
}
@@ -48,22 +45,15 @@ struct MutelistView: View {
}
.navigationTitle(NSLocalizedString("Muted Users", comment: "Navigation title of view to see list of muted users."))
.onAppear {
users = get_mutelist_users(damus_state.contacts.mutelist)
users = get_mutelist_users(damus_state.contacts.mutelist)
}
}
}
func get_mutelist_users(_ mlist: NostrEvent?) -> [String] {
guard let mutelist = mlist else {
return []
}
return mutelist.tags.reduce(into: Array<String>()) { pks, tag in
if tag.count >= 2 && tag[0] == "p" {
pks.append(tag[1])
}
}
func get_mutelist_users(_ mutelist: NostrEvent?) -> Array<Pubkey> {
guard let mutelist else { return [] }
return Array(mutelist.referenced_pubkeys)
}
struct MutelistView_Previews: PreviewProvider {