Files
damus/damus/Views/ReplyView.swift
William Casarin 22cad4b072 wot: show friend icons is some views
easier to detect if someone is trying to fake us out

Changelog-Added: Friend icons next to names on some views. Check is friend. Arrows are friend-of-friends
Signed-off-by: William Casarin <jb55@jb55.com>
2022-08-09 16:48:47 -07:00

51 lines
1.4 KiB
Swift

//
// ReplyView.swift
// damus
//
// Created by William Casarin on 2022-04-17.
//
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
let damus: DamusState
var body: some View {
VStack {
Text("Replying to:")
HStack(alignment: .top) {
let names = all_referenced_pubkeys(replying_to)
.map { pubkey in
let pk = pubkey.ref_id
let prof = damus.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, damus: damus, show_friend_icon: true)
PostView(references: gather_reply_ids(our_pubkey: damus.pubkey, from: replying_to))
}
.padding()
}
}
struct ReplyView_Previews: PreviewProvider {
static var previews: some View {
ReplyView(replying_to: NostrEvent(content: "hi", pubkey: "pubkey"), damus: test_damus_state())
}
}