nozaps: don't show note zaps in notifications

apple sucks
This commit is contained in:
William Casarin
2023-06-22 09:50:58 +02:00
parent 601fa49a6e
commit c5b0e539d8

View File

@@ -56,11 +56,16 @@ enum ReactingTo {
case your_profile case your_profile
} }
func determine_reacting_to(our_pubkey: String, ev: NostrEvent?) -> ReactingTo { func determine_reacting_to(our_pubkey: String, ev: NostrEvent?, group: EventGroupType, nozaps: Bool) -> ReactingTo {
guard let ev else { guard let ev else {
return .your_profile return .your_profile
} }
if nozaps && group.is_note_zap {
// ZAPPING NOTES IS NOT ALLOWED!!!! EVIL!!!
return .your_profile
}
if ev.pubkey == our_pubkey { if ev.pubkey == our_pubkey {
return .your_note return .your_note
} }
@@ -125,13 +130,13 @@ func event_group_author_name(profiles: Profiles, ind: Int, group: EventGroupType
"zapped_your_profile_2" - returned when 2 zaps occurred to the current user's profile "zapped_your_profile_2" - returned when 2 zaps occurred to the current user's profile
"zapped_your_profile_3" - returned when 3 or more zaps occurred to the current user's profile "zapped_your_profile_3" - returned when 3 or more zaps occurred to the current user's profile
*/ */
func reacting_to_text(profiles: Profiles, our_pubkey: String, group: EventGroupType, ev: NostrEvent?, locale: Locale? = nil) -> String { func reacting_to_text(profiles: Profiles, our_pubkey: String, group: EventGroupType, ev: NostrEvent?, nozaps: Bool, locale: Locale? = nil) -> String {
if group.events.count == 0 { if group.events.count == 0 {
return "??" return "??"
} }
let verb = reacting_to_verb(group: group) let verb = reacting_to_verb(group: group)
let reacting_to = determine_reacting_to(our_pubkey: our_pubkey, ev: ev) let reacting_to = determine_reacting_to(our_pubkey: our_pubkey, ev: ev, group: group, nozaps: nozaps)
let localization_key = "\(verb)_\(reacting_to)_\(min(group.events.count, 3))" let localization_key = "\(verb)_\(reacting_to)_\(min(group.events.count, 3))"
let format = localizedStringFormat(key: localization_key, locale: locale) let format = localizedStringFormat(key: localization_key, locale: locale)
@@ -171,7 +176,7 @@ struct EventGroupView: View {
let group: EventGroupType let group: EventGroupType
var GroupDescription: some View { var GroupDescription: some View {
Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event))") Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, nozaps: state.settings.nozaps))")
} }
func ZapIcon(_ zapgrp: ZapGroup) -> some View { func ZapIcon(_ zapgrp: ZapGroup) -> some View {
@@ -216,16 +221,18 @@ struct EventGroupView: View {
if let event { if let event {
let thread = ThreadModel(event: event, damus_state: state) let thread = ThreadModel(event: event, damus_state: state)
let dest = ThreadView(state: state, thread: thread) let dest = ThreadView(state: state, thread: thread)
NavigationLink(destination: dest) { GroupDescription
VStack(alignment: .leading) { if !state.settings.nozaps || !group.is_note_zap {
GroupDescription NavigationLink(destination: dest) {
EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content]) VStack(alignment: .leading) {
.padding([.top], 1) EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content])
.padding([.trailing]) .padding([.top], 1)
.foregroundColor(.gray) .padding([.trailing])
.foregroundColor(.gray)
}
} }
.buttonStyle(.plain)
} }
.buttonStyle(.plain)
} else { } else {
GroupDescription GroupDescription
} }