damus

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

commit f500da03e86b273c6c3de2fce7dac942c7e36741
parent 8a230861bf15090bbd3b7b03a602619173366580
Author: William Casarin <jb55@jb55.com>
Date:   Sun,  9 Apr 2023 22:45:38 -0700

nip27: handle nrelay a bit better

Diffstat:
Mdamus/Models/EventRef.swift | 2++
Mdamus/Models/Mentions.swift | 16++++++++++++++--
Mdamus/Views/NoteContentView.swift | 4++++
3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/damus/Models/EventRef.swift b/damus/Models/EventRef.swift @@ -78,6 +78,8 @@ func build_mention_indices(_ blocks: [Block], type: MentionType) -> Set<Int> { acc.insert(idx) } } + case .relay: + return case .text: return case .hashtag: diff --git a/damus/Models/Mentions.swift b/damus/Models/Mentions.swift @@ -81,6 +81,7 @@ enum Block: Equatable { case hashtag(String) case url(URL) case invoice(Invoice) + case relay(String) var is_invoice: Invoice? { if case .invoice(let invoice) = self { @@ -138,6 +139,8 @@ func render_blocks(blocks: [Block]) -> String { } else { return str + "nostr:\(bech32_note_id(m.ref.ref_id)!)" } + case .relay(let relay): + return str + relay case .text(let txt): return str + txt case .hashtag(let htag): @@ -362,9 +365,18 @@ func convert_mention_bech32_block(_ b: mention_bech32_block) -> Block? return .mention(Mention(index: nil, type: .pubkey, ref: pubkey_ref)) case NOSTR_BECH32_NRELAY: - fallthrough + let nrelay = b.bech32.data.nrelay + guard let relay_str = strblock_to_string(nrelay.relay) else { + return nil + } + return .relay(relay_str) + case NOSTR_BECH32_NADDR: - return .text(strblock_to_string(b.str)!) + // TODO: wtf do I do with this + guard let naddr = strblock_to_string(b.str) else { + return nil + } + return .text("nostr:" + naddr) default: return nil diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift @@ -162,6 +162,7 @@ struct NoteContentView: View { if m.type == .pubkey && m.ref.ref_id == profile.pubkey { self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey) } + case .relay: return case .text: return case .hashtag: return case .url: return @@ -313,6 +314,9 @@ func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?) -> Not } return str + CompatibleText(stringLiteral: trimmed) + case .relay(let relay): + return str + CompatibleText(stringLiteral: relay) + case .hashtag(let htag): return str + hashtag_str(htag) case .invoice(let invoice):