damus

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

commit 0ac321895201de18744db0354787f572d21e29e1
parent 550f09680893543440a396caa52ea34a0cfa2e1a
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 17 Apr 2022 11:40:48 -0700

fix reply ids

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/ContentView.swift | 2+-
Mdamus/Nostr/NostrEvent.swift | 11+++++++----
Mdamus/Views/ReplyView.swift | 2+-
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/damus/ContentView.swift b/damus/ContentView.swift @@ -121,7 +121,7 @@ struct ContentView: View { let privkey = "" let new_ev = NostrEvent(content: post.content, pubkey: pubkey) for id in post.references { - var tag = ["e", id.ref_id] + var tag = [id.key, id.ref_id] if let relay_id = id.relay_id { tag.append(relay_id) } diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift @@ -22,6 +22,7 @@ struct KeyEvent { struct ReferencedId { let ref_id: String let relay_id: String? + let key: String } struct EventId: Identifiable, CustomStringConvertible { @@ -59,7 +60,7 @@ class NostrEvent: Codable, Identifiable { if tag.count >= 3 { relay_id = tag[2] } - acc.append(ReferencedId(ref_id: tag[1], relay_id: relay_id)) + acc.append(ReferencedId(ref_id: tag[1], relay_id: relay_id, key: key)) } } } @@ -86,9 +87,11 @@ class NostrEvent: Codable, Identifiable { return false } - public func reply_ids() -> [ReferencedId] { - var ids = self.referenced_ids.first.map { [$0] } ?? [] - ids.append(ReferencedId(ref_id: self.id, relay_id: nil)) + public func reply_ids(pubkey: String) -> [ReferencedId] { + var ids = self.referenced_ids + ids.append(contentsOf: self.referenced_pubkeys) + ids.append(ReferencedId(ref_id: self.id, relay_id: nil, key: "e")) + ids.append(ReferencedId(ref_id: pubkey, relay_id: nil, key: "p")) return ids } diff --git a/damus/Views/ReplyView.swift b/damus/Views/ReplyView.swift @@ -14,7 +14,7 @@ struct ReplyView: View { VStack { Text("Replying to:") EventView(event: replying_to, highlight: .none, has_action_bar: false) - PostView(references: replying_to.reply_ids()) + PostView(references: replying_to.reply_ids(pubkey: replying_to.pubkey)) Spacer() }