damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 9fa11118d3838e3a279442cf05e0e38693d3e3ab
parent 2eeeb081fd5d1803eb4cea6dc7bdee79b34b45b8
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 30 Jan 2023 12:43:24 -0800

Fix some more context menu bugs

Diffstat:
Mdamus/Views/ChatroomView.swift | 2+-
Mdamus/Views/DMChatView.swift | 2+-
Mdamus/Views/EventView.swift | 6+++---
Mdamus/Views/Events/EmbeddedEventView.swift | 2+-
Mdamus/Views/Events/EventMenu.swift | 14+++++++-------
Mdamus/Views/Events/SelectedEventView.swift | 2+-
6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/damus/Views/ChatroomView.swift b/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, pubkey: ev.pubkey) + .event_context_menu(ev, keypair: damus.keypair, target_pubkey: ev.pubkey) .onTapGesture { if thread.initial_event.id == ev.id { //dismiss() diff --git a/damus/Views/DMChatView.swift b/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, pubkey: ev.pubkey) + .event_context_menu(ev, keypair: damus_state.keypair, target_pubkey: ev.pubkey) } EndBlock(height: 80) } diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -129,7 +129,7 @@ struct EventView: View { .id(event.id) .frame(maxWidth: .infinity, minHeight: PFP_SIZE) .padding([.bottom], 2) - .event_context_menu(event, privkey: damus.keypair.privkey, pubkey: pubkey) + .event_context_menu(event, keypair: damus.keypair, target_pubkey: pubkey) } } @@ -171,9 +171,9 @@ extension View { } } - func event_context_menu(_ event: NostrEvent, privkey: String?, pubkey: String) -> some View { + func event_context_menu(_ event: NostrEvent, keypair: Keypair, target_pubkey: String) -> some View { return self.contextMenu { - EventMenuContext(event: event, privkey: privkey, pubkey: pubkey) + EventMenuContext(event: event, keypair: keypair, target_pubkey: target_pubkey) } } diff --git a/damus/Views/Events/EmbeddedEventView.swift b/damus/Views/Events/EmbeddedEventView.swift @@ -23,7 +23,7 @@ struct EmbeddedEventView: View { EventBody(damus_state: damus_state, event: event, size: .small) } - .event_context_menu(event, privkey: damus_state.keypair.privkey, pubkey: pubkey) + .event_context_menu(event, keypair: damus_state.keypair, target_pubkey: pubkey) } } diff --git a/damus/Views/Events/EventMenu.swift b/damus/Views/Events/EventMenu.swift @@ -9,19 +9,19 @@ import SwiftUI struct EventMenuContext: View { let event: NostrEvent - let privkey: String? - let pubkey: String + let keypair: Keypair + let target_pubkey: String var body: some View { Button { - UIPasteboard.general.string = event.get_content(privkey) + UIPasteboard.general.string = event.get_content(keypair.privkey) } label: { Label(NSLocalizedString("Copy Text", comment: "Context menu option for copying the text from an note."), systemImage: "doc.on.doc") } Button { - UIPasteboard.general.string = bech32_pubkey(event.pubkey) + UIPasteboard.general.string = bech32_pubkey(target_pubkey) } label: { Label(NSLocalizedString("Copy User Pubkey", comment: "Context menu option for copying the ID of the user who created the note."), systemImage: "person") } @@ -45,16 +45,16 @@ struct EventMenuContext: View { } // Only allow reporting if logged in with private key and the currently viewed profile is not the logged in profile. - if pubkey != event.pubkey && privkey != nil { + if keypair.pubkey != target_pubkey && keypair.privkey != nil { Button(role: .destructive) { - let target: ReportTarget = .note(ReportNoteTarget(pubkey: event.pubkey, note_id: event.id)) + let target: ReportTarget = .note(ReportNoteTarget(pubkey: target_pubkey, note_id: event.id)) notify(.report, target) } label: { Label(NSLocalizedString("Report", comment: "Context menu option for reporting content."), systemImage: "exclamationmark.bubble") } Button(role: .destructive) { - notify(.block, event.pubkey) + notify(.block, target_pubkey) } label: { Label(NSLocalizedString("Block", comment: "Context menu option for blocking users."), systemImage: "exclamationmark.octagon") } diff --git a/damus/Views/Events/SelectedEventView.swift b/damus/Views/Events/SelectedEventView.swift @@ -49,7 +49,7 @@ struct SelectedEventView: View { .padding([.top], 4) } .padding([.leading], 2) - .event_context_menu(event, privkey: damus.keypair.privkey, pubkey: event.pubkey) + .event_context_menu(event, keypair: damus.keypair, target_pubkey: event.pubkey) } } }