nip19: add EventLoaderView for nevent mentions

Allow nevent mentions to be loaded in the MentionView since they are
just a note with extra metadata.

Lightning-url: LNURL1DP68GURN8GHJ7EM9W3SKCCNE9E3K7MF0D3H82UNVWQHKWUN9V4HXGCTHDC6RZVGR8SW3G
Signed-off-by: kernelkind <kernelkind@gmail.com>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
kernelkind
2024-01-18 14:59:28 -05:00
committed by William Casarin
parent d07ad67778
commit 3056ab9bfb

View File

@@ -739,22 +739,30 @@ func validate_event(ev: NostrEvent) -> ValidationResult {
func first_eref_mention(ev: NostrEvent, keypair: Keypair) -> Mention<NoteId>? { func first_eref_mention(ev: NostrEvent, keypair: Keypair) -> Mention<NoteId>? {
let blocks = ev.blocks(keypair).blocks.filter { block in let blocks = ev.blocks(keypair).blocks.filter { block in
guard case .mention(let mention) = block, guard case .mention(let mention) = block else {
case .note = mention.ref else { return false
}
switch mention.ref {
case .note, .nevent:
return true
default:
return false return false
} }
return true
} }
/// MARK: - Preview /// MARK: - Preview
if let firstBlock = blocks.first, if let firstBlock = blocks.first,
case .mention(let mention) = firstBlock, case .mention(let mention) = firstBlock {
case .note(let note_id) = mention.ref switch mention.ref {
{ case .note(let note_id):
return .note(note_id) return .note(note_id)
case .nevent(let nevent):
return .note(nevent.noteid)
default:
return nil
}
} }
return nil return nil
} }