From 7b739bddcef38e3c701fcd611ca6465935211cf2 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 20 May 2019 12:54:57 +1000 Subject: [PATCH] Implement expired friend request UI --- Signal/src/Loki/FriendRequestView.swift | 29 ++++++++----------- .../translations/en.lproj/Localizable.strings | 2 ++ .../SSKProtoPrekeyBundleMessage.swift | 10 ++----- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/Signal/src/Loki/FriendRequestView.swift b/Signal/src/Loki/FriendRequestView.swift index 96205360e..5c71cee12 100644 --- a/Signal/src/Loki/FriendRequestView.swift +++ b/Signal/src/Loki/FriendRequestView.swift @@ -83,27 +83,22 @@ switch kind { case .incoming: guard let message = message as? TSIncomingMessage else { preconditionFailure() } - buttonStackView.isHidden = didAcceptRequest || didDeclineRequest - let text: String = { - if didAcceptRequest { - return String(format: NSLocalizedString("You've accepted %@'s friend request", comment: ""), message.authorId) - } else if didDeclineRequest { - return String(format: NSLocalizedString("You've declined %@'s friend request", comment: ""), message.authorId) - } else { - return String(format: NSLocalizedString("%@ sent you a friend request", comment: ""), message.authorId) - } + buttonStackView.isHidden = didAcceptRequest || didDeclineRequest || message.isFriendRequestExpired + let format: String = { + if didAcceptRequest { return NSLocalizedString("You've accepted %@'s friend request", comment: "") } + else if didDeclineRequest { return NSLocalizedString("You've declined %@'s friend request", comment: "") } + else if message.isFriendRequestExpired { return NSLocalizedString("%@'s friend request has expired", comment: "") } + else { return NSLocalizedString("%@ sent you a friend request", comment: "") } }() - label.text = text + label.text = String(format: format, message.authorId) case .outgoing: guard let message = message as? TSOutgoingMessage else { preconditionFailure() } - let text: String = { - if didAcceptRequest { - return String(format: NSLocalizedString("%@ accepted your friend request", comment: ""), message.thread.contactIdentifier()!) - } else { - return String(format: NSLocalizedString("You've sent %@ a friend request", comment: ""), message.thread.contactIdentifier()!) - } + let format: String = { + if didAcceptRequest { return NSLocalizedString("%@ accepted your friend request", comment: "") } + else if message.isFriendRequestExpired { return NSLocalizedString("Your friend request to %@ has expired", comment: "") } + else { return NSLocalizedString("You've sent %@ a friend request", comment: "") } }() - label.text = text + label.text = String(format: format, message.thread.contactIdentifier()!) } } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index de69579b5..7b2cf4c82 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2582,3 +2582,5 @@ "You've declined %@'s friend request" = "You've declined %@'s friend request"; "You've accepted %@'s friend request" = "You've accepted %@'s friend request"; "%@ accepted your friend request" = "%@ accepted your friend request"; +"%@'s friend request has expired" = "%@'s friend request has expired"; +"Your friend request to %@ has expired" = "Your friend request to %@ has expired"; diff --git a/SignalServiceKit/src/Loki/Extensions/SSKProtoPrekeyBundleMessage.swift b/SignalServiceKit/src/Loki/Extensions/SSKProtoPrekeyBundleMessage.swift index 3c8572800..e907709b0 100644 --- a/SignalServiceKit/src/Loki/Extensions/SSKProtoPrekeyBundleMessage.swift +++ b/SignalServiceKit/src/Loki/Extensions/SSKProtoPrekeyBundleMessage.swift @@ -16,13 +16,7 @@ @objc public func createPreKeyBundle(withTransaction transaction: YapDatabaseReadWriteTransaction) -> PreKeyBundle? { let registrationId = TSAccountManager.sharedInstance().getOrGenerateRegistrationId(transaction) - return PreKeyBundle(registrationId: Int32(registrationId), - deviceId: Int32(deviceID), - preKeyId: Int32(prekeyID), - preKeyPublic: prekey, - signedPreKeyPublic: signedKey, - signedPreKeyId: Int32(signedKeyID), - signedPreKeySignature: signature, - identityKey: identityKey) + return PreKeyBundle(registrationId: Int32(registrationId), deviceId: Int32(deviceID), preKeyId: Int32(prekeyID), preKeyPublic: prekey, + signedPreKeyPublic: signedKey, signedPreKeyId: Int32(signedKeyID), signedPreKeySignature: signature, identityKey: identityKey) } }