Wait for note in NostrDB before rendering it

Closes: https://github.com/damus-io/damus/issues/2885
Changelog-Changed: Use NostrDB for rendering note contents
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-04-09 22:49:37 -07:00
parent 8f32c81b6c
commit b5afa3c0b4
5 changed files with 21 additions and 6 deletions

View File

@@ -376,7 +376,7 @@ func preload_event(plan: PreloadPlan, state: DamusState) async {
//print("Preloading event \(plan.event.content)")
if artifacts == nil && plan.load_artifacts {
let arts = render_note_content(ndb: state.ndb, ev: plan.event, profiles: profiles, keypair: our_keypair)
let arts = await ContentRenderer().render_note_content(ndb: state.ndb, ev: plan.event, profiles: profiles, keypair: our_keypair)
artifacts = arts
// we need these asap
@@ -397,7 +397,13 @@ func preload_event(plan: PreloadPlan, state: DamusState) async {
}
if plan.load_preview, note_artifact_is_separated(kind: plan.event.known_kind) {
let arts = artifacts ?? render_note_content(ndb: state.ndb, ev: plan.event, profiles: profiles, keypair: our_keypair)
let arts: NoteArtifacts
if let artifacts {
arts = artifacts
}
else {
arts = await ContentRenderer().render_note_content(ndb: state.ndb, ev: plan.event, profiles: profiles, keypair: our_keypair)
}
// only separated artifacts have previews
if case .separated(let sep) = arts {