damus

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

commit d2efe06610668db199611d49b8f0e5af84fe8f2d
parent ebcfe3c25ff857796c8efbf667551600cee450b7
Author: Bryan Montz <bryanmontz@me.com>
Date:   Fri,  7 Jul 2023 07:07:01 -0500

make "Copy Note JSON" a developer mode setting

Signed-off-by: Bryan Montz <bryanmontz@me.com>

Diffstat:
Mdamus/Views/DMChatView.swift | 2+-
Mdamus/Views/Events/EventMenu.swift | 17+++++++++++------
Mdamus/Views/Events/SelectedEventView.swift | 2+-
Mdamus/Views/Events/TextEvent.swift | 2+-
4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/damus/Views/DMChatView.swift b/damus/Views/DMChatView.swift @@ -23,7 +23,7 @@ struct DMChatView: View, KeyboardReadable { LazyVStack(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) - .contextMenu{MenuItems(event: ev, keypair: damus_state.keypair, target_pubkey: ev.pubkey, bookmarks: damus_state.bookmarks, muted_threads: damus_state.muted_threads)} + .contextMenu{MenuItems(event: ev, keypair: damus_state.keypair, target_pubkey: ev.pubkey, bookmarks: damus_state.bookmarks, muted_threads: damus_state.muted_threads, settings: damus_state.settings)} } EndBlock(height: 1) } diff --git a/damus/Views/Events/EventMenu.swift b/damus/Views/Events/EventMenu.swift @@ -13,12 +13,13 @@ struct EventMenuContext: View { let target_pubkey: String let bookmarks: BookmarksManager let muted_threads: MutedThreadsManager + @ObservedObject var settings: UserSettingsStore var body: some View { HStack { Menu { - MenuItems(event: event, keypair: keypair, target_pubkey: target_pubkey, bookmarks: bookmarks, muted_threads: muted_threads) + MenuItems(event: event, keypair: keypair, target_pubkey: target_pubkey, bookmarks: bookmarks, muted_threads: muted_threads, settings: settings) } label: { Label("", systemImage: "ellipsis") @@ -36,11 +37,12 @@ struct MenuItems: View { let target_pubkey: String let bookmarks: BookmarksManager let muted_threads: MutedThreadsManager + @ObservedObject var settings: UserSettingsStore @State private var isBookmarked: Bool = false @State private var isMutedThread: Bool = false - init(event: NostrEvent, keypair: Keypair, target_pubkey: String, bookmarks: BookmarksManager, muted_threads: MutedThreadsManager) { + init(event: NostrEvent, keypair: Keypair, target_pubkey: String, bookmarks: BookmarksManager, muted_threads: MutedThreadsManager, settings: UserSettingsStore) { let bookmarked = bookmarks.isBookmarked(event) self._isBookmarked = State(initialValue: bookmarked) @@ -52,6 +54,7 @@ struct MenuItems: View { self.event = event self.keypair = keypair self.target_pubkey = target_pubkey + self.settings = settings } var body: some View { @@ -75,10 +78,12 @@ struct MenuItems: View { Label(NSLocalizedString("Copy note ID", comment: "Context menu option for copying the ID of the note."), image: "note-book") } - Button { - UIPasteboard.general.string = event_to_json(ev: event) - } label: { - Label(NSLocalizedString("Copy note JSON", comment: "Context menu option for copying the JSON text from the note."), image: "code.on.square") + if settings.developer_mode { + Button { + UIPasteboard.general.string = event_to_json(ev: event) + } label: { + Label(NSLocalizedString("Copy note JSON", comment: "Context menu option for copying the JSON text from the note."), image: "code.on.square") + } } Button { diff --git a/damus/Views/Events/SelectedEventView.swift b/damus/Views/Events/SelectedEventView.swift @@ -35,7 +35,7 @@ struct SelectedEventView: View { Spacer() - EventMenuContext(event: event, keypair: damus.keypair, target_pubkey: event.pubkey, bookmarks: damus.bookmarks, muted_threads: damus.muted_threads) + EventMenuContext(event: event, keypair: damus.keypair, target_pubkey: event.pubkey, bookmarks: damus.bookmarks, muted_threads: damus.muted_threads, settings: damus.settings) .padding([.bottom], 4) } diff --git a/damus/Views/Events/TextEvent.swift b/damus/Views/Events/TextEvent.swift @@ -126,7 +126,7 @@ struct TextEvent: View { } var ContextButton: some View { - EventMenuContext(event: event, keypair: damus.keypair, target_pubkey: event.pubkey, bookmarks: damus.bookmarks, muted_threads: damus.muted_threads) + EventMenuContext(event: event, keypair: damus.keypair, target_pubkey: event.pubkey, bookmarks: damus.bookmarks, muted_threads: damus.muted_threads, settings: damus.settings) .padding([.bottom], 4) }