damus

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

commit 3056ab9bfb8e601900598927ef0b7870d2e19ade
parent d07ad67778825811eed62da5f2750e92205c2840
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 18 Jan 2024 14:59:28 -0500

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>

Diffstat:
Mdamus/Nostr/NostrEvent.swift | 26+++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

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