damus

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

commit 7c08d4af45e8d0a149acadcbe25cd9cd41d1e159
parent c7bf1da797b49a62aa9f1d64b3ea0c71fa485b85
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  6 Apr 2023 10:27:15 -0700

perf: cache note artifacts

Diffstat:
Mdamus/Views/NoteContentView.swift | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift @@ -42,7 +42,13 @@ struct NoteContentView: View { self._artifacts = State(initialValue: artifacts) self.preview_height = lookup_cached_preview_size(previews: damus_state.previews, evid: event.id) self._preview = State(initialValue: load_cached_preview(previews: damus_state.previews, evid: event.id)) - self._artifacts = State(initialValue: render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey)) + if let cache = damus_state.events.lookup_artifacts(evid: event.id) { + self._artifacts = State(initialValue: cache) + } else { + let artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey) + damus_state.events.store_artifacts(evid: event.id, artifacts: artifacts) + self._artifacts = State(initialValue: artifacts) + } } var truncate: Bool {