Implement expired friend request UI

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

@ -83,27 +83,22 @@
switch kind { switch kind {
case .incoming: case .incoming:
guard let message = message as? TSIncomingMessage else { preconditionFailure() } guard let message = message as? TSIncomingMessage else { preconditionFailure() }
buttonStackView.isHidden = didAcceptRequest || didDeclineRequest buttonStackView.isHidden = didAcceptRequest || didDeclineRequest || message.isFriendRequestExpired
let text: String = { let format: String = {
if didAcceptRequest { if didAcceptRequest { return NSLocalizedString("You've accepted %@'s friend request", comment: "") }
return String(format: NSLocalizedString("You've accepted %@'s friend request", comment: ""), message.authorId) else if didDeclineRequest { return NSLocalizedString("You've declined %@'s friend request", comment: "") }
} else if didDeclineRequest { else if message.isFriendRequestExpired { return NSLocalizedString("%@'s friend request has expired", comment: "") }
return String(format: NSLocalizedString("You've declined %@'s friend request", comment: ""), message.authorId) else { return NSLocalizedString("%@ sent you a friend request", comment: "") }
} else {
return String(format: NSLocalizedString("%@ sent you a friend request", comment: ""), message.authorId)
}
}() }()
label.text = text label.text = String(format: format, message.authorId)
case .outgoing: case .outgoing:
guard let message = message as? TSOutgoingMessage else { preconditionFailure() } guard let message = message as? TSOutgoingMessage else { preconditionFailure() }
let text: String = { let format: String = {
if didAcceptRequest { if didAcceptRequest { return NSLocalizedString("%@ accepted your friend request", comment: "") }
return String(format: NSLocalizedString("%@ accepted your friend request", comment: ""), message.thread.contactIdentifier()!) else if message.isFriendRequestExpired { return NSLocalizedString("Your friend request to %@ has expired", comment: "") }
} else { else { return NSLocalizedString("You've sent %@ a friend request", comment: "") }
return String(format: NSLocalizedString("You've sent %@ a friend request", comment: ""), message.thread.contactIdentifier()!)
}
}() }()
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 declined %@'s friend request" = "You've declined %@'s friend request";
"You've accepted %@'s friend request" = "You've accepted %@'s friend request"; "You've accepted %@'s friend request" = "You've accepted %@'s friend request";
"%@ accepted your friend request" = "%@ accepted your 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? { @objc public func createPreKeyBundle(withTransaction transaction: YapDatabaseReadWriteTransaction) -> PreKeyBundle? {
let registrationId = TSAccountManager.sharedInstance().getOrGenerateRegistrationId(transaction) let registrationId = TSAccountManager.sharedInstance().getOrGenerateRegistrationId(transaction)
return PreKeyBundle(registrationId: Int32(registrationId), return PreKeyBundle(registrationId: Int32(registrationId), deviceId: Int32(deviceID), preKeyId: Int32(prekeyID), preKeyPublic: prekey,
deviceId: Int32(deviceID), signedPreKeyPublic: signedKey, signedPreKeyId: Int32(signedKeyID), signedPreKeySignature: signature, identityKey: identityKey)
preKeyId: Int32(prekeyID),
preKeyPublic: prekey,
signedPreKeyPublic: signedKey,
signedPreKeyId: Int32(signedKeyID),
signedPreKeySignature: signature,
identityKey: identityKey)
} }
} }

Loading…
Cancel
Save