Compare commits

..

1 Commits

Author SHA1 Message Date
ce6bd4d4e3 Fix local notification content rendering of repost and reaction events
Changelog-Fixed: Fix local notification content rendering of repost and reaction events
2023-06-25 07:35:26 -04:00
23 changed files with 100 additions and 233 deletions

View File

@@ -96,10 +96,9 @@ Contributors welcome! Start by examining known issues: https://github.com/damus-
### Code
[Email patches][git-send-email] to jb55@jb55.com are preferred, but I accept PRs on GitHub as well. 50,000 sats will be rewarded for patches sent via email or [nostr][patchstr]
[Email patches][git-send-email] to jb55@jb55.com are preferred, but I accept PRs on GitHub as well.
[git-send-email]: http://git-send-email.io
[patchstr]: https://patchstr.com
### Privacy
Your internet protocol (IP) address is exposed to the relays you connect to, and third party media hosters (e.g. nostr.build, imgur.com, giphy.com, youtube.com etc.) that render on Damus. If you want to improve your privacy, consider utilizing a service that masks your IP address (e.g. a VPN) from trackers online.

View File

@@ -2236,7 +2236,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
DEVELOPMENT_TEAM = XK7H4JAB3D;
ENABLE_PREVIEWS = YES;
@@ -2284,7 +2284,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
DEVELOPMENT_TEAM = XK7H4JAB3D;
ENABLE_PREVIEWS = YES;

View File

@@ -38,6 +38,10 @@ struct ZapButton: View {
}
var zap_img: String {
if damus_state.settings.nozaps {
return "zap"
}
switch our_zap {
case .none:
return "zap"
@@ -49,6 +53,10 @@ struct ZapButton: View {
}
var zap_color: Color {
if damus_state.settings.nozaps {
return Color.gray
}
if our_zap == nil {
return Color.gray
}
@@ -106,17 +114,17 @@ struct ZapButton: View {
var body: some View {
HStack(spacing: 4) {
if zaps.zap_total > 0 {
Button(action: {
}, label: {
Image(zap_img)
.resizable()
.foregroundColor(zap_color)
.font(.footnote.weight(.medium))
.aspectRatio(contentMode: .fit)
.frame(width:20, height: 20)
})
Button(action: {
}, label: {
Image(zap_img)
.resizable()
.foregroundColor(zap_color)
.font(.footnote.weight(.medium))
.aspectRatio(contentMode: .fit)
.frame(width:20, height: 20)
})
if !damus_state.settings.nozaps && zaps.zap_total > 0 {
Text(verbatim: format_msats_abbrev(zaps.zap_total))
.font(.footnote)
.foregroundColor(zap_color)
@@ -126,7 +134,7 @@ struct ZapButton: View {
.simultaneousGesture(LongPressGesture().onEnded {_ in
// when we don't have nozaps mode enable, long press shows the zap customizer
if !damus_state.settings.nozaps {
//present_sheet(.zap(target: target, lnurl: lnurl))
present_sheet(.zap(target: target, lnurl: lnurl))
}
// long press does nothing in nozaps mode
@@ -134,7 +142,7 @@ struct ZapButton: View {
.highPriorityGesture(TapGesture().onEnded {
// when we have appstore mode on, only show the zap customizer as "user zaps"
if damus_state.settings.nozaps {
//present_sheet(.zap(target: target, lnurl: lnurl))
present_sheet(.zap(target: target, lnurl: lnurl))
} else {
// otherwise we restore the original behavior of one-tap zaps
tap()

View File

@@ -1076,7 +1076,7 @@ func zap_notification_title(_ zap: Zap) -> String {
func zap_notification_body(profiles: Profiles, zap: Zap, locale: Locale = Locale.current) -> String {
let src = zap.request.ev
let pk = zap.is_anon ? ANON_PUBKEY : src.pubkey
let pk = zap.is_anon ? "anon" : src.pubkey
let profile = profiles.lookup(id: pk)
let sats = NSNumber(value: (Double(zap.invoice.amount) / 1000.0))
let formattedSats = format_msats_abbrev(zap.invoice.amount)

View File

@@ -76,7 +76,7 @@ class ProfileModel: ObservableObject, Equatable {
profile_filter.authors = [pubkey]
text_filter.authors = [pubkey]
text_filter.limit = 50
text_filter.limit = 500
print("subscribing to profile \(pubkey) with sub_id \(sub_id)")
print_filters(relay_id: "profile", filters: [[text_filter], [profile_filter]])

View File

@@ -38,7 +38,7 @@ enum DisplayName {
func parse_display_name(profile: Profile?, pubkey: String) -> DisplayName {
if pubkey == ANON_PUBKEY {
if pubkey == "anon" {
return .one(NSLocalizedString("Anonymous", comment: "Placeholder display name of anonymous user."))
}

View File

@@ -9,7 +9,6 @@ import Foundation
import secp256k1
let PUBKEY_HRP = "npub"
let ANON_PUBKEY = "anon"
struct FullKeypair: Equatable {
let pubkey: String

View File

@@ -19,7 +19,11 @@ struct EventDetailBar: View {
self.target = target
self.target_pk = target_pk
self._bar = ObservedObject(wrappedValue: make_actionbar_model(ev: target, damus: state))
}
var ZapDetails: Text {
let noun = Text(verbatim: zapsCountString(bar.zaps)).foregroundColor(.gray)
return Text("\(Text(verbatim: bar.zaps.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.")
}
var body: some View {
@@ -40,13 +44,11 @@ struct EventDetailBar: View {
.buttonStyle(PlainButtonStyle())
}
if bar.zaps > 0 {
if !state.settings.nozaps && bar.zaps > 0 {
let dst = ZapsView(state: state, target: .note(id: target, author: target_pk))
NavigationLink(destination: dst) {
let noun = Text(verbatim: zapsCountString(bar.zaps)).foregroundColor(.gray)
Text("\(Text(verbatim: bar.zaps.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.")
}
.buttonStyle(PlainButtonStyle())
ZapDetails
}.buttonStyle(PlainButtonStyle())
}
}
}

View File

@@ -132,7 +132,7 @@ struct TextEvent: View {
func ProfileName(is_anon: Bool) -> some View {
let profile = damus.profiles.lookup(id: pubkey)
let pk = is_anon ? ANON_PUBKEY : pubkey
let pk = is_anon ? "anon" : pubkey
return EventProfileName(pubkey: pk, profile: profile, damus: damus, size: .normal)
}

View File

@@ -56,11 +56,16 @@ enum ReactingTo {
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 {
return .your_profile
}
if nozaps && group.is_note_zap {
// ZAPPING NOTES IS NOT ALLOWED!!!! EVIL!!!
return .your_profile
}
if ev.pubkey == our_pubkey {
return .your_note
}
@@ -73,42 +78,19 @@ func event_author_name(profiles: Profiles, pubkey: String) -> String {
return Profile.displayName(profile: alice_prof, pubkey: pubkey).username.truncate(maxLength: 50)
}
func event_group_unique_pubkeys(profiles: Profiles, group: EventGroupType) -> [String] {
var seen = Set<String>()
var sorted = [String]()
func event_group_author_name(profiles: Profiles, ind: Int, group: EventGroupType) -> String {
if let zapgrp = group.zap_group {
let zaps = zapgrp.zaps
for i in 0..<zaps.count {
let zap = zapgrp.zaps[i]
let pubkey: String
if zap.is_anon {
pubkey = ANON_PUBKEY
} else {
pubkey = zap.request.ev.pubkey
}
if !seen.contains(pubkey) {
seen.insert(pubkey)
sorted.append(pubkey)
}
let zap = zapgrp.zaps[ind]
if zap.is_anon {
return NSLocalizedString("Anonymous", comment: "Placeholder author name of the anonymous person who zapped an event.")
}
return event_author_name(profiles: profiles, pubkey: zap.request.ev.pubkey)
} else {
let events = group.events
for i in 0..<events.count {
let ev = events[i]
let pubkey = ev.pubkey
if !seen.contains(pubkey) {
seen.insert(pubkey)
sorted.append(pubkey)
}
}
let ev = group.events[ind]
return event_author_name(profiles: profiles, pubkey: ev.pubkey)
}
return sorted
}
/**
@@ -148,29 +130,29 @@ 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_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?, pubkeys: [String], 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 {
return "??"
}
let verb = reacting_to_verb(group: group)
let reacting_to = determine_reacting_to(our_pubkey: our_pubkey, ev: ev)
let localization_key = "\(verb)_\(reacting_to)_\(min(pubkeys.count, 3))"
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 format = localizedStringFormat(key: localization_key, locale: locale)
switch pubkeys.count {
switch group.events.count {
case 1:
let display_name = event_author_name(profiles: profiles, pubkey: pubkeys[0])
let display_name = event_group_author_name(profiles: profiles, ind: 0, group: group)
return String(format: format, locale: locale, display_name)
case 2:
let alice_name = event_author_name(profiles: profiles, pubkey: pubkeys[0])
let bob_name = event_author_name(profiles: profiles, pubkey: pubkeys[1])
let alice_name = event_group_author_name(profiles: profiles, ind: 0, group: group)
let bob_name = event_group_author_name(profiles: profiles, ind: 1, group: group)
return String(format: format, locale: locale, alice_name, bob_name)
default:
let alice_name = event_author_name(profiles: profiles, pubkey: pubkeys[0])
let count = pubkeys.count - 1
let alice_name = event_group_author_name(profiles: profiles, ind: 0, group: group)
let count = group.events.count - 1
return String(format: format, locale: locale, count, alice_name)
}
@@ -193,8 +175,8 @@ struct EventGroupView: View {
let event: NostrEvent?
let group: EventGroupType
func GroupDescription(_ pubkeys: [String]) -> some View {
Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys))")
var GroupDescription: some View {
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 {
@@ -234,25 +216,25 @@ struct EventGroupView: View {
.frame(width: PFP_SIZE + 10)
VStack(alignment: .leading) {
let unique_pubkeys = event_group_unique_pubkeys(profiles: state.profiles, group: group)
ProfilePicturesView(state: state, pubkeys: unique_pubkeys)
ProfilePicturesView(state: state, pubkeys: group.events.map { $0.pubkey })
if let event {
let thread = ThreadModel(event: event, damus_state: state)
let dest = ThreadView(state: state, thread: thread)
NavigationLink(destination: dest) {
VStack(alignment: .leading) {
GroupDescription(unique_pubkeys)
EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content])
.padding([.top], 1)
.padding([.trailing])
.foregroundColor(.gray)
GroupDescription
if !state.settings.nozaps || !group.is_note_zap {
NavigationLink(destination: dest) {
VStack(alignment: .leading) {
EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content])
.padding([.top], 1)
.padding([.trailing])
.foregroundColor(.gray)
}
}
.buttonStyle(.plain)
}
.buttonStyle(.plain)
} else {
GroupDescription(unique_pubkeys)
GroupDescription
}
}
}

View File

@@ -38,6 +38,6 @@ struct MaybeAnonPfpView: View {
struct MaybeAnonPfpView_Previews: PreviewProvider {
static var previews: some View {
MaybeAnonPfpView(state: test_damus_state(), is_anon: true, pubkey: ANON_PUBKEY, size: PFP_SIZE)
MaybeAnonPfpView(state: test_damus_state(), is_anon: true, pubkey: "anon", size: PFP_SIZE)
}
}

View File

@@ -48,8 +48,7 @@ public class VideoPlayerModel: ObservableObject {
@Published var has_audio: Bool? = nil
@Published var contentMode: UIView.ContentMode = .scaleAspectFill
fileprivate var time: CMTime?
var time: CMTime = CMTime()
var handlers: [VideoHandler] = []
init() {
@@ -263,9 +262,8 @@ extension VideoPlayer: UIViewRepresentable {
uiView.isMuted = model.muted
uiView.isAutoReplay = model.autoReplay
if let observerTime = context.coordinator.observerTime, let modelTime = model.time,
modelTime != observerTime && modelTime.isValid && modelTime.isNumeric {
uiView.seek(to: modelTime, completion: { _ in })
if let observerTime = context.coordinator.observerTime, model.time != observerTime {
uiView.seek(to: model.time, toleranceBefore: model.time, toleranceAfter: model.time, completion: { _ in })
}
}

View File

@@ -23,6 +23,6 @@ struct ZapUserView: View {
struct ZapUserView_Previews: PreviewProvider {
static var previews: some View {
ZapUserView(state: test_damus_state(), pubkey: ANON_PUBKEY)
ZapUserView(state: test_damus_state(), pubkey: "anon")
}
}

View File

@@ -18,22 +18,6 @@
<string>... %d άλλες σημειώσεις ...</string>
</dict>
</dict>
<key>followed_by_three_and_others</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@OTHERS@</string>
<key>OTHERS</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Σας ακολούθησε %2$@, %3$@, %4$@ &amp; %1$d ακόμα</string>
<key>other</key>
<string>Σας ακολούθησαν %2$@, %3$@, %4$@ &amp; %1$d ακόμα</string>
</dict>
</dict>
<key>followers_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
@@ -333,9 +317,9 @@
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%2$@ και %1$d ακόμα σας έστειλε zap</string>
<string>%2$@ και %1$d ακόμα έστειλε zap στο προφίλ σας</string>
<key>other</key>
<string>%2$@ και %1$d ακόμα σας έστειλαν zap</string>
<string>%2$@ και %1$d ακόμα έστειλαν zap στο προφίλ σας</string>
</dict>
</dict>
<key>zaps_count</key>

View File

@@ -45,7 +45,7 @@
<trans-unit id="%@ %@" xml:space="preserve">
<source>%@ %@</source>
<target>%@ %@</target>
<note>Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.
<note>Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.
Sentence composed of 2 variables to describe how many people are following a user. In source English, the first variable is the number of followers, and the second variable is 'Follower' or 'Followers'.</note>
</trans-unit>
<trans-unit id="%@ has been muted" xml:space="preserve">
@@ -276,6 +276,11 @@ Sentence composed of 2 variables to describe how many people are following a use
<note>Sidebar menu label for Bookmarks view.
Title of bookmarks view</note>
</trans-unit>
<trans-unit id="Boosts" xml:space="preserve">
<source>Boosts</source>
<target>Boosts</target>
<note>Accessibility label for boosts button</note>
</trans-unit>
<trans-unit id="Broadcast" xml:space="preserve">
<source>Broadcast</source>
<target>Broadcast</target>
@@ -571,31 +576,11 @@ Sentence composed of 2 variables to describe how many people are following a use
<target>Follow me on Nostr</target>
<note>Text on QR code view to prompt viewer looking at screen to follow the user.</note>
</trans-unit>
<trans-unit id="Followed by %@" xml:space="preserve">
<source>Followed by %@</source>
<target>Followed by %@</target>
<note>Text to indicate that the user is followed by one of our follows.</note>
</trans-unit>
<trans-unit id="Followed by %@ &amp; %@" xml:space="preserve">
<source>Followed by %1$@ &amp; %2$@</source>
<target>Followed by %1$@ &amp; %2$@</target>
<note>Text to indicate that the user is followed by two of our follows.</note>
</trans-unit>
<trans-unit id="Followed by %@, %@ &amp; %@" xml:space="preserve">
<source>Followed by %1$@, %2$@ &amp; %3$@</source>
<target>Followed by %1$@, %2$@ &amp; %3$@</target>
<note>Text to indicate that the user is followed by three of our follows.</note>
</trans-unit>
<trans-unit id="Followers" xml:space="preserve">
<source>Followers</source>
<target>Followers</target>
<note>Navigation bar title for view that shows who is following a user.</note>
</trans-unit>
<trans-unit id="Followers You Know" xml:space="preserve">
<source>Followers You Know</source>
<target>Followers You Know</target>
<note>Navigation bar title for view that shows who is following a user.</note>
</trans-unit>
<trans-unit id="Following" xml:space="preserve">
<source>Following</source>
<target>Following</target>
@@ -1166,8 +1151,7 @@ Button text to indicate that the zap type is a private zap.</note>
<trans-unit id="Reposts" xml:space="preserve">
<source>Reposts</source>
<target>Reposts</target>
<note>Accessibility label for boosts button
Navigation bar title for Reposts view.
<note>Navigation bar title for Reposts view.
Setting to enable Repost Local Notification</note>
</trans-unit>
<trans-unit id="Requests" xml:space="preserve">
@@ -1246,9 +1230,9 @@ Button text to indicate that the zap type is a private zap.</note>
<target>Send a message to start the conversation...</target>
<note>Text prompt for user to send a message to the other user.</note>
</trans-unit>
<trans-unit id="Send a message with your zap..." xml:space="preserve">
<source>Send a message with your zap...</source>
<target>Send a message with your zap...</target>
<trans-unit id="Send a reply with your zap..." xml:space="preserve">
<source>Send a reply with your zap...</source>
<target>Send a reply with your zap...</target>
<note>Placeholder text for a comment to send as part of a zap to the user.</note>
</trans-unit>
<trans-unit id="Server" xml:space="preserve">
@@ -1636,13 +1620,9 @@ YOU WILL NO LONGER BE ABLE TO LOG INTO DAMUS USING THIS ACCOUNT KEY.
<source>Zap</source>
<target>Zap</target>
<note>Accessibility label for zap button
Button to send a zap.
Title of notification when a non-private zap is received.</note>
</trans-unit>
<trans-unit id="Zap User" xml:space="preserve">
<source>Zap User</source>
<target>Zap User</target>
<note>Button to send a zap.</note>
</trans-unit>
<trans-unit id="Zap Vibration" xml:space="preserve">
<source>Zap Vibration</source>
<target>Zap Vibration</target>
@@ -1854,21 +1834,6 @@ YOU WILL NO LONGER BE ABLE TO LOG INTO DAMUS USING THIS ACCOUNT KEY.
<target>%#@NOTES@</target>
<note/>
</trans-unit>
<trans-unit id="/followed_by_three_and_others:dict/NSStringLocalizedFormatKey:dict/:string" xml:space="preserve">
<source>%#@OTHERS@</source>
<target>%#@OTHERS@</target>
<note/>
</trans-unit>
<trans-unit id="/followed_by_three_and_others:dict/OTHERS:dict/one:dict/:string" xml:space="preserve">
<source>Followed by %2$@, %3$@, %4$@ &amp; %1$d other</source>
<target>Followed by %2$@, %3$@, %4$@ &amp; %1$d other</target>
<note/>
</trans-unit>
<trans-unit id="/followed_by_three_and_others:dict/OTHERS:dict/other:dict/:string" xml:space="preserve">
<source>Followed by %2$@, %3$@, %4$@ &amp; %1$d others</source>
<target>Followed by %2$@, %3$@, %4$@ &amp; %1$d others</target>
<note/>
</trans-unit>
<trans-unit id="/followers_count:dict/FOLLOWERS:dict/one:dict/:string" xml:space="preserve">
<source>Follower</source>
<target>Follower</target>

View File

@@ -18,22 +18,6 @@
<string>... %d other notes ...</string>
</dict>
</dict>
<key>followed_by_three_and_others</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@OTHERS@</string>
<key>OTHERS</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Followed by %2$@, %3$@, %4$@ &amp; %1$d other</string>
<key>other</key>
<string>Followed by %2$@, %3$@, %4$@ &amp; %1$d others</string>
</dict>
</dict>
<key>followers_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>

Binary file not shown.

View File

@@ -18,22 +18,6 @@
<string>... %d andere notities ...</string>
</dict>
</dict>
<key>followed_by_three_and_others</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@OTHERS@</string>
<key>OTHERS</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Gevolgd door %2$@, %3$@, %4$@ en %1$d andere gebruiker</string>
<key>other</key>
<string>Gevolgd door %2$@, %3$@, %4$@ en %1$d andere gebruikers</string>
</dict>
</dict>
<key>followers_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>

View File

@@ -18,22 +18,6 @@
<string>...%d andra anteckningar...</string>
</dict>
</dict>
<key>followed_by_three_and_others</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@OTHERS@</string>
<key>OTHERS</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Följd av %2$@, %3$@, %4$@ &amp; %1$d andra</string>
<key>other</key>
<string>Följd av %2$@, %3$@, %4$@ &amp; %1$d andra</string>
</dict>
</dict>
<key>followers_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
@@ -333,9 +317,9 @@
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%2$@ och %1$d andra zapped dig</string>
<string>%2$@ och %1$d annan zappade din profil</string>
<key>other</key>
<string>%2$@ och %1$d andra zapped dig</string>
<string>%2$@ och %1$d andra zappade din profil</string>
</dict>
</dict>
<key>zaps_count</key>

View File

@@ -18,27 +18,6 @@ final class EventGroupViewTests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testEventAuthorName() {
let damusState = test_damus_state()
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: "pk1"), "pk1:pk1")
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: "pk2"), "pk2:pk2")
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: "anon"), "Anonymous")
}
func testEventGroupUniquePubkeys() {
let damusState = test_damus_state()
let encodedPost = "{\"id\": \"8ba545ab96959fe0ce7db31bc10f3ac3aa5353bc4428dbf1e56a7be7062516db\",\"pubkey\": \"7e27509ccf1e297e1df164912a43406218f8bd80129424c3ef798ca3ef5c8444\",\"created_at\": 1677013417,\"kind\": 1,\"tags\": [],\"content\": \"hello\",\"sig\": \"93684f15eddf11f42afbdd81828ee9fc35350344d8650c78909099d776e9ad8d959cd5c4bff7045be3b0b255144add43d0feef97940794a1bc9c309791bebe4a\"}"
let repost1 = NostrEvent(id: "", content: encodedPost, pubkey: "pk1", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
let repost2 = NostrEvent(id: "", content: encodedPost, pubkey: "pk2", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
let repost3 = NostrEvent(id: "", content: encodedPost, pubkey: "pk3", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
XCTAssertEqual(event_group_unique_pubkeys(profiles: damusState.profiles, group: .repost(EventGroup(events: []))), [])
XCTAssertEqual(event_group_unique_pubkeys(profiles: damusState.profiles, group: .repost(EventGroup(events: [repost1]))), ["pk1"])
XCTAssertEqual(event_group_unique_pubkeys(profiles: damusState.profiles, group: .repost(EventGroup(events: [repost1, repost2]))), ["pk1", "pk2"])
XCTAssertEqual(event_group_unique_pubkeys(profiles: damusState.profiles, group: .repost(EventGroup(events: [repost1, repost2, repost3]))), ["pk1", "pk2", "pk3"])
}
func testReactingToText() throws {
let enUsLocale = Locale(identifier: "en-US")
let damusState = test_damus_state()
@@ -46,19 +25,18 @@ final class EventGroupViewTests: XCTestCase {
let encodedPost = "{\"id\": \"8ba545ab96959fe0ce7db31bc10f3ac3aa5353bc4428dbf1e56a7be7062516db\",\"pubkey\": \"7e27509ccf1e297e1df164912a43406218f8bd80129424c3ef798ca3ef5c8444\",\"created_at\": 1677013417,\"kind\": 1,\"tags\": [],\"content\": \"hello\",\"sig\": \"93684f15eddf11f42afbdd81828ee9fc35350344d8650c78909099d776e9ad8d959cd5c4bff7045be3b0b255144add43d0feef97940794a1bc9c309791bebe4a\"}"
let repost1 = NostrEvent(id: "", content: encodedPost, pubkey: "pk1", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
let repost2 = NostrEvent(id: "", content: encodedPost, pubkey: "pk2", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
let repost3 = NostrEvent(id: "", content: encodedPost, pubkey: "pk3", kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)
let nozaps = true
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_event, pubkeys: [], locale: enUsLocale), "??")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_event, pubkeys: ["pk1"], locale: enUsLocale), "pk1:pk1 reposted a note you were tagged in")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_event, pubkeys: ["pk1", "pk2"], locale: enUsLocale), "pk1:pk1 and pk2:pk2 reposted a note you were tagged in")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost2])), ev: test_event, pubkeys: ["pk1", "pk2", "pk3"], locale: enUsLocale), "pk1:pk1 and 2 others reposted a note you were tagged in")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_event, nozaps: nozaps, locale: enUsLocale), "??")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_event, nozaps: nozaps, locale: enUsLocale), "pk1:pk1 reposted a note you were tagged in")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_event, nozaps: nozaps, locale: enUsLocale), "pk1:pk1 and pk2:pk2 reposted a note you were tagged in")
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost2])), ev: test_event, nozaps: nozaps, locale: enUsLocale), "pk1:pk1 and 2 others reposted a note you were tagged in")
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_event, pubkeys: [], locale: $0), "??")
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_event, pubkeys: ["pk1"], locale: $0))
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_event, pubkeys: ["pk1", "pk2"], locale: $0))
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost3])), ev: test_event, pubkeys: ["pk1", "pk2", "pk3"], locale: $0))
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_event, nozaps: nozaps, locale: $0), "??")
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_event, nozaps: nozaps, locale: $0))
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_event, nozaps: nozaps, locale: $0))
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost2])), ev: test_event, nozaps: nozaps, locale: $0))
}
}