Prevent blocking or reporting yourself
This commit is contained in:
@@ -24,7 +24,7 @@ struct ChatroomView: View {
|
|||||||
next_ev: ind == count-1 ? nil : thread.events[ind+1],
|
next_ev: ind == count-1 ? nil : thread.events[ind+1],
|
||||||
damus_state: damus
|
damus_state: damus
|
||||||
)
|
)
|
||||||
.event_context_menu(ev, pubkey: ev.pubkey, privkey: damus.keypair.privkey)
|
.event_context_menu(ev, keypair: damus.keypair)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if thread.initial_event.id == ev.id {
|
if thread.initial_event.id == ev.id {
|
||||||
//dismiss()
|
//dismiss()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct DMChatView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
ForEach(Array(zip(dms.events, dms.events.indices)), id: \.0.id) { (ev, ind) in
|
ForEach(Array(zip(dms.events, dms.events.indices)), id: \.0.id) { (ev, ind) in
|
||||||
DMView(event: dms.events[ind], damus_state: damus_state)
|
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)
|
EndBlock(height: 80)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ struct EventView: View {
|
|||||||
.id(event.id)
|
.id(event.id)
|
||||||
.frame(maxWidth: .infinity, minHeight: PFP_SIZE)
|
.frame(maxWidth: .infinity, minHeight: PFP_SIZE)
|
||||||
.padding([.bottom], 2)
|
.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 {
|
return self.contextMenu {
|
||||||
EventMenuContext(event: event, privkey: privkey, pubkey: pubkey)
|
EventMenuContext(event: event, keypair: keypair)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct EmbeddedEventView: View {
|
|||||||
|
|
||||||
EventBody(damus_state: damus_state, event: event, size: .small)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,19 +9,18 @@ import SwiftUI
|
|||||||
|
|
||||||
struct EventMenuContext: View {
|
struct EventMenuContext: View {
|
||||||
let event: NostrEvent
|
let event: NostrEvent
|
||||||
let privkey: String?
|
let keypair: Keypair
|
||||||
let pubkey: String
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
UIPasteboard.general.string = event.get_content(privkey)
|
UIPasteboard.general.string = event.get_content(keypair.privkey)
|
||||||
} label: {
|
} label: {
|
||||||
Label(NSLocalizedString("Copy Text", comment: "Context menu option for copying the text from an note."), systemImage: "doc.on.doc")
|
Label(NSLocalizedString("Copy Text", comment: "Context menu option for copying the text from an note."), systemImage: "doc.on.doc")
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
UIPasteboard.general.string = bech32_pubkey(pubkey) ?? pubkey
|
UIPasteboard.general.string = keypair.pubkey_bech32
|
||||||
} label: {
|
} label: {
|
||||||
Label(NSLocalizedString("Copy User Pubkey", comment: "Context menu option for copying the ID of the user who created the note."), systemImage: "person")
|
Label(NSLocalizedString("Copy User Pubkey", comment: "Context menu option for copying the ID of the user who created the note."), systemImage: "person")
|
||||||
}
|
}
|
||||||
@@ -38,24 +37,27 @@ struct EventMenuContext: View {
|
|||||||
Label(NSLocalizedString("Copy Note JSON", comment: "Context menu option for copying the JSON text from the note."), systemImage: "square.on.square")
|
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 {
|
Button {
|
||||||
NotificationCenter.default.post(name: .broadcast_event, object: event)
|
NotificationCenter.default.post(name: .broadcast_event, object: event)
|
||||||
} label: {
|
} 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")
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ struct SelectedEventView: View {
|
|||||||
.padding([.top], 4)
|
.padding([.top], 4)
|
||||||
}
|
}
|
||||||
.padding([.leading], 2)
|
.padding([.leading], 2)
|
||||||
.event_context_menu(event, pubkey: pubkey, privkey: damus.keypair.privkey)
|
.event_context_menu(event, keypair: damus.keypair)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,13 +379,16 @@ struct ProfileView: View {
|
|||||||
show_share_sheet = true
|
show_share_sheet = true
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
|
// Only allow reporting if logged in with private key and the currently viewed profile is not the logged in profile.
|
||||||
let target: ReportTarget = .user(profile.pubkey)
|
if profile.pubkey != damus_state.pubkey && damus_state.is_privkey_user {
|
||||||
notify(.report, target)
|
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) {
|
Button(NSLocalizedString("Block", comment: "Button to block a profile."), role: .destructive) {
|
||||||
notify(.block, profile.pubkey)
|
notify(.block, profile.pubkey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
|||||||
Reference in New Issue
Block a user