dms: always use the other persons pubkey in context menu

The DM view can sometimes show our last message, which means the pubkey
in the context menu would be ours. This is super confusing, so always
use the other persons pubkey when copying the user id in the DMs view.

Changlog-Fixed: Always copy other persons pubkey in DMs context menus
This commit is contained in:
William Casarin
2023-01-07 11:29:24 -08:00
parent 08dd2d5414
commit c10fcc52e3
3 changed files with 5 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ struct ChatroomView: View {
next_ev: ind == count-1 ? nil : thread.events[ind+1],
damus_state: damus
)
.event_context_menu(ev, privkey: damus.keypair.privkey)
.event_context_menu(ev, pubkey: ev.pubkey, privkey: damus.keypair.privkey)
.onTapGesture {
if thread.initial_event.id == ev.id {
//dismiss()

View File

@@ -19,7 +19,7 @@ struct DMChatView: View {
VStack(alignment: .leading) {
ForEach(Array(zip(dms.events, dms.events.indices)), id: \.0.id) { (ev, ind) in
DMView(event: dms.events[ind], damus_state: damus_state)
.event_context_menu(ev, privkey: damus_state.keypair.privkey)
.event_context_menu(ev, pubkey: ev.pubkey, privkey: damus_state.keypair.privkey)
}
EndBlock(height: 80)
}

View File

@@ -274,7 +274,7 @@ struct EventView: View {
.id(event.id)
.frame(maxWidth: .infinity, minHeight: PFP_SIZE)
.padding([.bottom], 2)
.event_context_menu(event, privkey: damus.keypair.privkey)
.event_context_menu(event, pubkey: pubkey, privkey: damus.keypair.privkey)
}
}
@@ -313,7 +313,7 @@ extension View {
}
}
func event_context_menu(_ event: NostrEvent, privkey: String?) -> some View {
func event_context_menu(_ event: NostrEvent, pubkey: String, privkey: String?) -> some View {
return self.contextMenu {
Button {
UIPasteboard.general.string = event.get_content(privkey)
@@ -322,7 +322,7 @@ extension View {
}
Button {
UIPasteboard.general.string = bech32_pubkey(event.pubkey) ?? event.pubkey
UIPasteboard.general.string = bech32_pubkey(pubkey) ?? pubkey
} label: {
Label("Copy User ID", systemImage: "tag")
}