Browse Source

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
translations_damus-localizations-en-us-xcloc-localized-contents-en-us-xliff--master_es_419
William Casarin 2 years ago
parent
commit
c10fcc52e3
  1. 2
      damus/Views/ChatroomView.swift
  2. 2
      damus/Views/DMChatView.swift
  3. 6
      damus/Views/EventView.swift

2
damus/Views/ChatroomView.swift

@ -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()

2
damus/Views/DMChatView.swift

@ -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)
}

6
damus/Views/EventView.swift

@ -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")
}

Loading…
Cancel
Save