fix "Replying to..." issues and improve related tests

This commit is contained in:
Bryan Montz
2023-03-14 12:08:18 -05:00
committed by William Casarin
parent dd511c3061
commit cabe584938
3 changed files with 46 additions and 49 deletions

View File

@@ -41,17 +41,19 @@ func reply_desc(profiles: Profiles, event: NostrEvent, locale: Locale = Locale.c
let prof = profiles.lookup(id: $0)
return Profile.displayName(profile: prof, pubkey: $0)
}
let uniqueNames = NSOrderedSet(array: names).array as! [String]
if names.count > 1 {
if uniqueNames.count > 1 {
let othersCount = n - pubkeys.count
if othersCount == 0 {
return String(format: NSLocalizedString("Replying to %@ & %@", bundle: bundle, comment: "Label to indicate that the user is replying to 2 users."), locale: locale, names[0], names[1])
return String(format: NSLocalizedString("Replying to %@ & %@", bundle: bundle, comment: "Label to indicate that the user is replying to 2 users."), locale: locale, uniqueNames[0], uniqueNames[1])
} else {
return String(format: bundle.localizedString(forKey: "replying_to_two_and_others", value: nil, table: nil), locale: locale, othersCount, names[0], names[1])
return String(format: bundle.localizedString(forKey: "replying_to_two_and_others", value: nil, table: nil), locale: locale, othersCount, uniqueNames[0], uniqueNames[1])
}
}
return String(format: NSLocalizedString("Replying to %@", bundle: bundle, comment: "Label to indicate that the user is replying to 1 user."), locale: locale, names[0])
return String(format: NSLocalizedString("Replying to %@", bundle: bundle, comment: "Label to indicate that the user is replying to 1 user."), locale: locale, uniqueNames[0])
}