You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.9 KiB

//
// 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
@State var originalParticipants: [ReferencedId] = []
@State var participants: [ReferencedId] = []
var body: some View {
VStack {
Text("Replying to:", comment: "Indicating that the user is replying to the following listed people.")
HStack(alignment: .top) {
let names = participants
.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)
}
ScrollView {
EventView(event: replying_to, highlight: .none, has_action_bar: false, damus: damus, show_friend_icon: true)
ParticipantsView(damus: damus, participants: $participants, originalParticipants: $originalParticipants)
}
PostView(replying_to: replying_to, references: participants)
}
.onAppear {
participants = all_referenced_pubkeys(replying_to)
originalParticipants = participants
}
.padding()
}
}
struct ReplyView_Previews: PreviewProvider {
static var previews: some View {
ReplyView(replying_to: NostrEvent(content: "hi", pubkey: "pubkey"), damus: test_damus_state(), participants: [])
}
}