damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 4ac3da76121eebcf794b7ac5e8b68bbebcdf88eb
parent bb1f912f782f54e7cba8c6796fe2a859feb76b93
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  9 May 2024 14:34:02 -0700

events: try nostrdb cache if we don't have one in-memory

Our nip10 logic looks for notes only in the in-memory cache. This means
sometimes threads don't get fully loaded if for whatever reason it's in
the nostrdb cache but not in-memory.

Ideally we would just remove our in-memory cache, but for now let's just
hack it so it falls back to nostrdb and makes an owned note.

Changelog-Fixed: Fixed threads not loading sometimes
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Util/EventCache.swift | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/damus/Util/EventCache.swift b/damus/Util/EventCache.swift @@ -218,7 +218,16 @@ class EventCache { */ func lookup(_ evid: NoteId) -> NostrEvent? { - return events[evid] + if let ev = events[evid] { + return ev + } + + if let ev = self.ndb.lookup_note(evid)?.unsafeUnownedValue?.to_owned() { + events[ev.id] = ev + return ev + } + + return nil } func insert(_ ev: NostrEvent) {