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Mcd2{Q5XI$3@%$+9ztX
Yxi0nt^W+O0BAYpqJXpXCyYyR(0FdHCTmS$7
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
index bada26e..1df96c8 100644
--- a/damus/ContentView.swift
+++ b/damus/ContentView.swift
@@ -434,21 +434,26 @@ struct ContentView: View {
.onReceive(handle_notify(.new_mutes)) { notif in
home.filter_muted()
}
- .alert("User blocked", isPresented: $user_blocked_confirm, actions: {
- Button("Thanks!") {
+ .alert(NSLocalizedString("User blocked", comment: "Alert message to indicate "), isPresented: $user_blocked_confirm, actions: {
+ Button(NSLocalizedString("Thanks!", comment: "Button to close out of alert that informs that the action to block a user was successful.")) {
user_blocked_confirm = false
}
}, message: {
if let pubkey = self.blocking {
let profile = damus_state!.profiles.lookup(id: pubkey)
let name = Profile.displayName(profile: profile, pubkey: pubkey)
- Text("\(name) has been blocked")
+ Text("\(name) has been blocked", comment: "Alert message that informs a user was blocked.")
} else {
- Text("User has been blocked")
+ Text("User has been blocked", comment: "Alert message that informs a user was blocked.")
}
})
- .alert("Create new mutelist", isPresented: $confirm_overwrite_mutelist, actions: {
- Button("Yes, Overwrite") {
+ .alert(NSLocalizedString("Create new mutelist", comment: "Title of alert prompting the user to create a new mutelist."), isPresented: $confirm_overwrite_mutelist, actions: {
+ Button(NSLocalizedString("Cancel", comment: "Button to cancel out of alert that creates a new mutelist.")) {
+ confirm_overwrite_mutelist = false
+ confirm_block = false
+ }
+
+ Button(NSLocalizedString("Yes, Overwrite", comment: "Text of button that confirms to overwrite the existing mutelist.")) {
guard let ds = damus_state else {
return
}
@@ -472,20 +477,18 @@ struct ContentView: View {
confirm_block = false
user_blocked_confirm = true
}
-
- Button("Cancel") {
- confirm_overwrite_mutelist = false
- confirm_block = false
- }
}, message: {
- Text("No block list found, create a new one? This will overwrite any previous block lists.")
+ Text("No block list found, create a new one? This will overwrite any previous block lists.", comment: "Alert message prompt that asks if the user wants to create a new block list, overwriting previous block lists.")
})
- .alert("Block User", isPresented: $confirm_block, actions: {
- Button("Block") {
+ .alert(NSLocalizedString("Block User", comment: "Title of alert for blocking a user."), isPresented: $confirm_block, actions: {
+ Button(NSLocalizedString("Cancel", comment: "Alert button to cancel out of alert for blocking a user."), role: .cancel) {
+ confirm_block = false
+ }
+ Button(NSLocalizedString("Block", comment: "Alert button to block a user."), role: .destructive) {
guard let ds = damus_state else {
return
}
-
+
if ds.contacts.mutelist == nil {
confirm_overwrite_mutelist = true
} else {
@@ -495,7 +498,7 @@ struct ContentView: View {
guard let pubkey = blocking else {
return
}
-
+
guard let ev = create_or_update_mutelist(keypair: keypair, mprev: ds.contacts.mutelist, to_add: pubkey) else {
return
}
@@ -503,17 +506,13 @@ struct ContentView: View {
ds.pool.send(.event(ev))
}
}
-
- Button("Cancel") {
- confirm_block = false
- }
}, message: {
if let pubkey = blocking {
let profile = damus_state?.profiles.lookup(id: pubkey)
let name = Profile.displayName(profile: profile, pubkey: pubkey)
- Text("Block \(name)?")
+ Text("Block \(name)?", comment: "Alert message prompt to ask if a user should be blocked.")
} else {
- Text("Could not find user to block...")
+ Text("Could not find user to block...", comment: "Alert message to indicate that the blocked user could not be found.")
}
})
}
diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift
index 07d4b66..f586181 100644
--- a/damus/Views/ConfigView.swift
+++ b/damus/Views/ConfigView.swift
@@ -139,10 +139,10 @@ struct ConfigView: View {
.navigationTitle(NSLocalizedString("Settings", comment: "Navigation title for Settings view."))
.navigationBarTitleDisplayMode(.large)
.alert(NSLocalizedString("Logout", comment: "Alert for logging out the user."), isPresented: $confirm_logout) {
- Button(NSLocalizedString("Cancel", comment: "Cancel out of logging out the user.")) {
+ Button(NSLocalizedString("Cancel", comment: "Cancel out of logging out the user."), role: .cancel) {
confirm_logout = false
}
- Button(NSLocalizedString("Logout", comment: "Button for logging out the user.")) {
+ Button(NSLocalizedString("Logout", comment: "Button for logging out the user."), role: .destructive) {
notify(.logout, ())
}
} message: {
diff --git a/damus/Views/EULAView.swift b/damus/Views/EULAView.swift
index 3bdf1c3..eae670f 100644
--- a/damus/Views/EULAView.swift
+++ b/damus/Views/EULAView.swift
@@ -16,7 +16,7 @@ struct EULAView: View {
DamusGradient()
ScrollView {
- Text("EULA")
+ Text("EULA", comment: "Label indicating that the below text is the EULA, an acronym for End User License Agreement.")
.font(.title.bold())
.foregroundColor(.white)
@@ -72,11 +72,11 @@ By using our Application, you signify your acceptance of this EULA. If you do no
NavigationLink(destination: CreateAccountView(), isActive: $creating_account) {
EmptyView()
}
- DamusWhiteButton("Accept") {
+ DamusWhiteButton(NSLocalizedString("Accept", comment: "Button to accept the end user license agreement before being allowed into the app.")) {
creating_account = true
}
-
- DamusWhiteButton("Reject") {
+
+ DamusWhiteButton(NSLocalizedString("Reject", comment: "Button to reject the end user license agreement, which disallows the user from being let into the app.")) {
dismiss()
}
}
diff --git a/damus/Views/Events/EventMenu.swift b/damus/Views/Events/EventMenu.swift
index 8ab2ead..dc8ec18 100644
--- a/damus/Views/Events/EventMenu.swift
+++ b/damus/Views/Events/EventMenu.swift
@@ -38,14 +38,14 @@ struct EventMenuContext: View {
Label(NSLocalizedString("Copy Note JSON", comment: "Context menu option for copying the JSON text from the note."), systemImage: "square.on.square")
}
- Button {
+ Button(role: .destructive) {
let target: ReportTarget = .note(ReportNoteTarget(pubkey: event.pubkey, note_id: event.id))
notify(.report, target)
} label: {
Label(NSLocalizedString("Report", comment: "Context menu option for reporting content."), systemImage: "exclamationmark.bubble")
}
- Button {
+ Button(role: .destructive) {
notify(.block, event.pubkey)
} label: {
Label(NSLocalizedString("Block", comment: "Context menu option for blocking users."), systemImage: "exclamationmark.octagon")
diff --git a/damus/Views/Muting/MutelistView.swift b/damus/Views/Muting/MutelistView.swift
index c847e86..bbdc157 100644
--- a/damus/Views/Muting/MutelistView.swift
+++ b/damus/Views/Muting/MutelistView.swift
@@ -43,7 +43,7 @@ struct MutelistView: View {
RemoveAction(pubkey: pubkey)
}
}
- .navigationTitle("Blocked Users")
+ .navigationTitle(NSLocalizedString("Blocked Users", comment: "Navigation title of view to see list of blocked users."))
}
}
diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift
index 4bcd62c..a48412e 100644
--- a/damus/Views/ProfileView.swift
+++ b/damus/Views/ProfileView.swift
@@ -374,17 +374,17 @@ struct ProfileView: View {
}
}
}
- .confirmationDialog("Actions", isPresented: $action_sheet_presented) {
- Button("Share") {
+ .confirmationDialog(NSLocalizedString("Actions", comment: "Title for confirmation dialog to either share, report, or block a profile."), isPresented: $action_sheet_presented) {
+ Button(NSLocalizedString("Share", comment: "Button to share the link to a profile.")) {
show_share_sheet = true
}
- Button("Report") {
+ Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
let target: ReportTarget = .user(profile.pubkey)
notify(.report, target)
}
- Button("Block") {
+ Button(NSLocalizedString("Block", comment: "Button to block a profile."), role: .destructive) {
notify(.block, profile.pubkey)
}
}
diff --git a/damus/Views/ReportView.swift b/damus/Views/ReportView.swift
index b3286bc..d69a287 100644
--- a/damus/Views/ReportView.swift
+++ b/damus/Views/ReportView.swift
@@ -25,16 +25,16 @@ struct ReportView: View {
var Success: some View {
VStack(alignment: .center, spacing: 20) {
- Text("Report sent!")
+ Text("Report sent!", comment: "Message indicating that a report was successfully sent to relay servers.")
.font(.headline)
- Text("Relays have been notified and clients will be able to use this information to filter content. Thank you!")
+ Text("Relays have been notified and clients will be able to use this information to filter content. Thank you!", comment: "Description of what was done as a result of sending a report to relay servers.")
- Text("Report ID:")
+ Text("Report ID:", comment: "Label indicating that the text underneath is the identifier of the report that was sent to relay servers.")
Text(report_id)
- Button("Copy Report ID") {
+ Button(NSLocalizedString("Copy Report ID", comment: "Button to copy report ID.")) {
UIPasteboard.general.string = report_id
let g = UIImpactFeedbackGenerator(style: .medium)
g.impactOccurred()
@@ -59,33 +59,33 @@ struct ReportView: View {
var MainForm: some View {
VStack {
- Text("Report")
+ Text("Report", comment: "Label indicating that the current view is for the user to report content.")
.font(.headline)
.padding()
Form {
Section(content: {
- Button("It's spam") {
+ Button(NSLocalizedString("It's spam", comment: "Button for user to report that the account or content has spam.")) {
do_send_report(type: .spam)
}
- Button("Nudity or explicit content") {
+ Button(NSLocalizedString("Nudity or explicit content", comment: "Button for user to report that the account or content has nudity or explicit content.")) {
do_send_report(type: .explicit)
}
- Button("Illegal content") {
+ Button(NSLocalizedString("Illegal content", comment: "Button for user to report that the account or content has illegal content.")) {
do_send_report(type: .illegal)
}
if case .user = target {
- Button("They are impersonating someone") {
+ Button(NSLocalizedString("They are impersonating someone", comment: "Button for user to report that the account is impersonating someone.")) {
do_send_report(type: .impersonation)
}
}
}, header: {
- Text("What do you want to report?")
+ Text("What do you want to report?", comment: "Header text to prompt user what issue they want to report.")
}, footer: {
- Text("Your report will be sent to the relays you are connected to")
+ Text("Your report will be sent to the relays you are connected to", comment: "Footer text to inform user what will happen when the report is submitted.")
})
}
}
diff --git a/damus/Views/SideMenuView.swift b/damus/Views/SideMenuView.swift
index 9f9c72d..6ce48df 100644
--- a/damus/Views/SideMenuView.swift
+++ b/damus/Views/SideMenuView.swift
@@ -148,10 +148,10 @@ struct SideMenuView: View {
isSidebarVisible.toggle()
}
.alert("Logout", isPresented: $confirm_logout) {
- Button(NSLocalizedString("Cancel", comment: "Cancel out of logging out the user.")) {
+ Button(NSLocalizedString("Cancel", comment: "Cancel out of logging out the user."), role: .cancel) {
confirm_logout = false
}
- Button(NSLocalizedString("Logout", comment: "Button for logging out the user.")) {
+ Button(NSLocalizedString("Logout", comment: "Button for logging out the user."), role: .destructive) {
notify(.logout, ())
}
} message: {
From 3e02cc6889190f73711d41f3d18e76ada2db90fb Mon Sep 17 00:00:00 2001
From: Terry Yiu <963907+tyiu@users.noreply.github.com>
Date: Thu, 26 Jan 2023 23:34:21 -0500
Subject: [PATCH 3/3] Prevent blocking or reporting yourself
---
damus/Views/ChatroomView.swift | 2 +-
damus/Views/DMChatView.swift | 2 +-
damus/Views/EventView.swift | 6 ++--
damus/Views/Events/EmbeddedEventView.swift | 2 +-
damus/Views/Events/EventMenu.swift | 36 ++++++++++++----------
damus/Views/Events/SelectedEventView.swift | 2 +-
damus/Views/ProfileView.swift | 19 +++++++-----
7 files changed, 37 insertions(+), 32 deletions(-)
diff --git a/damus/Views/ChatroomView.swift b/damus/Views/ChatroomView.swift
index 0ce6727..ed38f7a 100644
--- 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, pubkey: ev.pubkey, privkey: damus.keypair.privkey)
+ .event_context_menu(ev, keypair: damus.keypair)
.onTapGesture {
if thread.initial_event.id == ev.id {
//dismiss()
diff --git a/damus/Views/DMChatView.swift b/damus/Views/DMChatView.swift
index 0c2f6ba..f963ced 100644
--- 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, pubkey: ev.pubkey, privkey: damus_state.keypair.privkey)
+ .event_context_menu(ev, keypair: damus_state.keypair)
}
EndBlock(height: 80)
}
diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift
index a305189..fab2e1d 100644
--- 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, pubkey: pubkey, privkey: damus.keypair.privkey)
+ .event_context_menu(event, keypair: damus.keypair)
}
}
@@ -171,9 +171,9 @@ extension View {
}
}
- func event_context_menu(_ event: NostrEvent, pubkey: String, privkey: String?) -> some View {
+ func event_context_menu(_ event: NostrEvent, keypair: Keypair) -> some View {
return self.contextMenu {
- EventMenuContext(event: event, privkey: privkey, pubkey: pubkey)
+ EventMenuContext(event: event, keypair: keypair)
}
}
diff --git a/damus/Views/Events/EmbeddedEventView.swift b/damus/Views/Events/EmbeddedEventView.swift
index beaa6ee..4d75368 100644
--- 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, pubkey: pubkey, privkey: damus_state.keypair.privkey)
+ .event_context_menu(event, keypair: damus_state.keypair)
}
}
diff --git a/damus/Views/Events/EventMenu.swift b/damus/Views/Events/EventMenu.swift
index dc8ec18..de0f8da 100644
--- a/damus/Views/Events/EventMenu.swift
+++ b/damus/Views/Events/EventMenu.swift
@@ -9,19 +9,18 @@ import SwiftUI
struct EventMenuContext: View {
let event: NostrEvent
- let privkey: String?
- let pubkey: String
+ let keypair: Keypair
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(pubkey) ?? pubkey
+ UIPasteboard.general.string = keypair.pubkey_bech32
} label: {
Label(NSLocalizedString("Copy User Pubkey", comment: "Context menu option for copying the ID of the user who created the note."), systemImage: "person")
}
@@ -37,25 +36,28 @@ struct EventMenuContext: View {
} label: {
Label(NSLocalizedString("Copy Note JSON", comment: "Context menu option for copying the JSON text from the note."), systemImage: "square.on.square")
}
-
- Button(role: .destructive) {
- let target: ReportTarget = .note(ReportNoteTarget(pubkey: event.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)
- } label: {
- Label(NSLocalizedString("Block", comment: "Context menu option for blocking users."), systemImage: "exclamationmark.octagon")
- }
Button {
NotificationCenter.default.post(name: .broadcast_event, object: event)
} label: {
Label(NSLocalizedString("Broadcast", comment: "Context menu option for broadcasting the user's note to all of the user's connected relay servers."), systemImage: "globe")
}
+
+ // Only allow reporting if logged in with private key and the currently viewed profile is not the logged in profile.
+ if keypair.pubkey != event.pubkey && keypair.privkey != nil {
+ Button(role: .destructive) {
+ let target: ReportTarget = .note(ReportNoteTarget(pubkey: event.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)
+ } 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
index f9c7186..f8f3c83 100644
--- 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, pubkey: pubkey, privkey: damus.keypair.privkey)
+ .event_context_menu(event, keypair: damus.keypair)
}
}
}
diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift
index a48412e..4be870a 100644
--- a/damus/Views/ProfileView.swift
+++ b/damus/Views/ProfileView.swift
@@ -378,14 +378,17 @@ struct ProfileView: View {
Button(NSLocalizedString("Share", comment: "Button to share the link to a profile.")) {
show_share_sheet = true
}
-
- Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
- let target: ReportTarget = .user(profile.pubkey)
- notify(.report, target)
- }
-
- Button(NSLocalizedString("Block", comment: "Button to block a profile."), role: .destructive) {
- notify(.block, profile.pubkey)
+
+ // Only allow reporting if logged in with private key and the currently viewed profile is not the logged in profile.
+ if profile.pubkey != damus_state.pubkey && damus_state.is_privkey_user {
+ Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
+ let target: ReportTarget = .user(profile.pubkey)
+ notify(.report, target)
+ }
+
+ Button(NSLocalizedString("Block", comment: "Button to block a profile."), role: .destructive) {
+ notify(.block, profile.pubkey)
+ }
}
}
.ignoresSafeArea()