Revert "nozaps: don't show note zaps in notifications"

This reverts commit c5b0e539d8.
This commit is contained in:
William Casarin
2023-06-27 05:58:39 +02:00
parent 1e2326cccf
commit 66db4c5215

View File

@@ -56,16 +56,11 @@ enum ReactingTo {
case your_profile case your_profile
} }
func determine_reacting_to(our_pubkey: String, ev: NostrEvent?, group: EventGroupType, nozaps: Bool) -> ReactingTo { func determine_reacting_to(our_pubkey: String, ev: NostrEvent?) -> 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
} }
@@ -153,13 +148,13 @@ func event_group_unique_pubkeys(profiles: Profiles, group: EventGroupType) -> [S
"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?, nozaps: Bool, pubkeys: [String], locale: Locale? = nil) -> String { func reacting_to_text(profiles: Profiles, our_pubkey: String, group: EventGroupType, ev: NostrEvent?, locale: Locale? = nil, pubkeys: [String]) -> String {
if pubkeys.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, group: group, nozaps: nozaps) let reacting_to = determine_reacting_to(our_pubkey: our_pubkey, ev: ev)
let localization_key = "\(verb)_\(reacting_to)_\(min(pubkeys.count, 3))" let localization_key = "\(verb)_\(reacting_to)_\(min(pubkeys.count, 3))"
let format = localizedStringFormat(key: localization_key, locale: locale) let format = localizedStringFormat(key: localization_key, locale: locale)
@@ -199,7 +194,7 @@ struct EventGroupView: View {
let group: EventGroupType let group: EventGroupType
func GroupDescription(_ pubkeys: [String]) -> some View { func GroupDescription(_ pubkeys: [String]) -> some View {
Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, nozaps: state.settings.nozaps, pubkeys: pubkeys))") Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys))")
} }
func ZapIcon(_ zapgrp: ZapGroup) -> some View { func ZapIcon(_ zapgrp: ZapGroup) -> some View {
@@ -246,20 +241,17 @@ 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)
GroupDescription(unique_pubkeys) NavigationLink(destination: dest) {
if !state.settings.nozaps || !group.is_note_zap { VStack(alignment: .leading) {
NavigationLink(destination: dest) { GroupDescription(unique_pubkeys)
VStack(alignment: .leading) { EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content])
EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content]) .padding([.top], 1)
.padding([.top], 1) .padding([.trailing])
.padding([.trailing]) .foregroundColor(.gray)
.foregroundColor(.gray)
}
} }
.buttonStyle(.plain)
} }
.buttonStyle(.plain)
} else { } else {
GroupDescription(unique_pubkeys)
} }
} }
} }