From 4ff6719961802a4f170af1f8d4b9c2ea12b83b69 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 17 Apr 2022 15:12:26 -0700 Subject: [PATCH] show who we're replying to Signed-off-by: William Casarin --- damus/Views/ReplyView.swift | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/damus/Views/ReplyView.swift b/damus/Views/ReplyView.swift index 8c2e3318..c38f4a2b 100644 --- a/damus/Views/ReplyView.swift +++ b/damus/Views/ReplyView.swift @@ -7,12 +7,33 @@ import SwiftUI +func all_referenced_pubkeys(_ ev: NostrEvent) -> [ReferencedId] { + var keys = ev.referenced_pubkeys + let ref = ReferencedId(ref_id: ev.pubkey, relay_id: nil, key: "p") + keys.insert(ref, at: 0) + return keys +} + struct ReplyView: View { let replying_to: NostrEvent + @EnvironmentObject var profiles: Profiles + var body: some View { VStack { Text("Replying to:") + HStack { + let names = all_referenced_pubkeys(replying_to) + .map { pubkey in + let pk = pubkey.ref_id + let prof = profiles.lookup(id: pk) + return Profile.displayName(profile: prof, pubkey: pk) + } + .joined(separator: ", ") + Text(names) + .foregroundColor(.gray) + .font(.footnote) + } EventView(event: replying_to, highlight: .none, has_action_bar: false) PostView(references: replying_to.reply_ids(pubkey: replying_to.pubkey))