mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix the pinned identity banner to always show the user ID regardless of ambiguity. (#3415)
This commit is contained in:
@@ -524,6 +524,14 @@ internal enum L10n {
|
||||
internal static func cryptoIdentityChangePinViolation(_ p1: Any, _ p2: Any) -> String {
|
||||
return L10n.tr("Localizable", "crypto_identity_change_pin_violation", String(describing: p1), String(describing: p2))
|
||||
}
|
||||
/// %1$@’s %2$@ identity appears to have changed. %3$@
|
||||
internal static func cryptoIdentityChangePinViolationNew(_ p1: Any, _ p2: Any, _ p3: Any) -> String {
|
||||
return L10n.tr("Localizable", "crypto_identity_change_pin_violation_new", String(describing: p1), String(describing: p2), String(describing: p3))
|
||||
}
|
||||
/// (%1$@)
|
||||
internal static func cryptoIdentityChangePinViolationNewUserId(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "crypto_identity_change_pin_violation_new_user_id", String(describing: p1))
|
||||
}
|
||||
/// In order to let the application use the camera, please grant the permission in the system settings.
|
||||
internal static var dialogPermissionCamera: String { return L10n.tr("Localizable", "dialog_permission_camera") }
|
||||
/// Please grant the permission in the system settings.
|
||||
|
||||
@@ -43,7 +43,8 @@ struct RoomScreenFooterView: View {
|
||||
avatarSize: .user(on: .timeline),
|
||||
mediaProvider: mediaProvider)
|
||||
|
||||
Text(pinViolationDescriptionWithLearnMoreLink(displayName: member.disambiguatedDisplayName ?? member.userID,
|
||||
Text(pinViolationDescriptionWithLearnMoreLink(displayName: member.displayName,
|
||||
userID: member.userID,
|
||||
url: learnMoreURL))
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
@@ -59,20 +60,39 @@ struct RoomScreenFooterView: View {
|
||||
.padding(.bottom, 8)
|
||||
}
|
||||
|
||||
private func pinViolationDescriptionWithLearnMoreLink(displayName: String, url: URL) -> AttributedString {
|
||||
private func pinViolationDescriptionWithLearnMoreLink(displayName: String?, userID: String, url: URL) -> AttributedString {
|
||||
let userIDPlaceholder = "{mxid}"
|
||||
let linkPlaceholder = "{link}"
|
||||
var description = AttributedString(L10n.cryptoIdentityChangePinViolation(displayName, linkPlaceholder))
|
||||
let displayName = displayName ?? fallbackDisplayName(userID)
|
||||
var description = AttributedString(L10n.cryptoIdentityChangePinViolationNew(displayName, userIDPlaceholder, linkPlaceholder))
|
||||
|
||||
var userIDString = AttributedString(L10n.cryptoIdentityChangePinViolationNewUserId(userID))
|
||||
userIDString.bold()
|
||||
description.replace(userIDPlaceholder, with: userIDString)
|
||||
|
||||
var linkString = AttributedString(L10n.actionLearnMore)
|
||||
linkString.link = url
|
||||
linkString.bold()
|
||||
description.replace(linkPlaceholder, with: linkString)
|
||||
return description
|
||||
}
|
||||
|
||||
private func fallbackDisplayName(_ userID: String) -> String {
|
||||
guard let localpart = userID.components(separatedBy: ":").first else { return userID }
|
||||
return String(localpart.trimmingPrefix("@"))
|
||||
}
|
||||
}
|
||||
|
||||
struct RoomScreenFooterView_Previews: PreviewProvider, TestablePreview {
|
||||
static let bobDetails: RoomScreenFooterViewDetails = .pinViolation(member: RoomMemberProxyMock.mockBob,
|
||||
learnMoreURL: "https://element.io/")
|
||||
static let noNameDetails: RoomScreenFooterViewDetails = .pinViolation(member: RoomMemberProxyMock.mockNoName,
|
||||
learnMoreURL: "https://element.io/")
|
||||
|
||||
static var previews: some View {
|
||||
RoomScreenFooterView(details: .pinViolation(member: RoomMemberProxyMock.mockBob, learnMoreURL: "https://element.io/"),
|
||||
mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
RoomScreenFooterView(details: bobDetails, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
.previewDisplayName("With displayname")
|
||||
RoomScreenFooterView(details: noNameDetails, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
.previewDisplayName("Without displayname")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user