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:
@@ -66,7 +66,7 @@ func note_artifact_is_separated(kind: NostrKind?) -> Bool {
|
||||
return kind != .longform
|
||||
}
|
||||
|
||||
func render_note_content(ndb: Ndb, ev: NostrEvent, profiles: Profiles, keypair: Keypair) -> NoteArtifacts {
|
||||
func render_immediately_available_note_content(ndb: Ndb, ev: NostrEvent, profiles: Profiles, keypair: Keypair) -> NoteArtifacts {
|
||||
guard let blocks = ev.blocks(ndb: ndb) else {
|
||||
return .separated(.just_content(ev.get_content(keypair)))
|
||||
}
|
||||
@@ -78,6 +78,15 @@ func render_note_content(ndb: Ndb, ev: NostrEvent, profiles: Profiles, keypair:
|
||||
return .separated(render_blocks(blocks: blocks.unsafeUnownedValue, profiles: profiles, note: ev, can_hide_last_previewable_refs: true))
|
||||
}
|
||||
|
||||
actor ContentRenderer {
|
||||
func render_note_content(ndb: Ndb, ev: NostrEvent, profiles: Profiles, keypair: Keypair) async -> NoteArtifacts {
|
||||
guard let result = try? await ndb.waitFor(noteId: ev.id, timeout: 10) else {
|
||||
return .separated(.just_content(ev.get_content(keypair)))
|
||||
}
|
||||
return render_immediately_available_note_content(ndb: ndb, ev: ev, profiles: profiles, keypair: keypair)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(tyiu): There are a lot of hacks to get this function to render the blocks correctly.
|
||||
// However, the entire note content rendering logic just needs to be rewritten.
|
||||
// Block previews should actually be rendered in the position of the note content where it was found.
|
||||
|
||||
Reference in New Issue
Block a user