Implement expired friend request UI

pull/16/head
Niels Andriesse 6 years ago
parent bab8cebc3f
commit 7b739bddce

@ -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()!)
}
}

@ -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";

@ -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)
}
}

Loading…
Cancel
Save