mirror of
git://jb55.com/damus
synced 2024-10-01 09:20:47 +00:00
profile: partially fix performance regression
This will be completely fixed once we switch to stored note blocks
This commit is contained in:
parent
54674104ea
commit
909701ce7b
@ -31,7 +31,8 @@ func nsfw_tag_filter(ev: NostrEvent) -> Bool {
|
|||||||
func get_repost_of_muted_user_filter(damus_state: DamusState) -> ((_ ev: NostrEvent) -> Bool) {
|
func get_repost_of_muted_user_filter(damus_state: DamusState) -> ((_ ev: NostrEvent) -> Bool) {
|
||||||
return { ev in
|
return { ev in
|
||||||
guard ev.known_kind == .boost else { return true }
|
guard ev.known_kind == .boost else { return true }
|
||||||
guard let inner_ev = ev.get_inner_event(cache: damus_state.events) else { return true }
|
// This needs to use cached because it can be way too slow otherwise
|
||||||
|
guard let inner_ev = ev.get_cached_inner_event(cache: damus_state.events) else { return true }
|
||||||
return should_show_event(keypair: damus_state.keypair, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: inner_ev)
|
return should_show_event(keypair: damus_state.keypair, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: inner_ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,11 @@ import Foundation
|
|||||||
|
|
||||||
// Extension to make NdbNote compatible with NostrEvent's original API
|
// Extension to make NdbNote compatible with NostrEvent's original API
|
||||||
extension NdbNote {
|
extension NdbNote {
|
||||||
func get_inner_event(cache: EventCache) -> NdbNote? {
|
func parse_inner_event() -> NdbNote? {
|
||||||
|
return NdbNote.owned_from_json_cstr(json: content_raw, json_len: content_len)
|
||||||
|
}
|
||||||
|
|
||||||
|
func get_cached_inner_event(cache: EventCache) -> NdbNote? {
|
||||||
guard self.known_kind == .boost else {
|
guard self.known_kind == .boost else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -19,6 +23,13 @@ extension NdbNote {
|
|||||||
return cache.lookup(id)
|
return cache.lookup(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.get_inner_event()
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func get_inner_event(cache: EventCache) -> NdbNote? {
|
||||||
|
if let ev = get_cached_inner_event(cache: cache) {
|
||||||
|
return ev
|
||||||
|
}
|
||||||
|
return self.parse_inner_event()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user