|
|
|
@ -213,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.message.isFriendRequest) {
|
|
|
|
|
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
|
|
|
|
self.friendRequestView = [[LKFriendRequestView alloc] initWithMessage:self.message];
|
|
|
|
|
self.friendRequestView.delegate = self.friendRequestViewDelegate;
|
|
|
|
|
[self.contentView addSubview:self.friendRequestView];
|
|
|
|
@ -383,7 +383,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
cellSize.width += self.sendFailureBadgeSize + self.sendFailureBadgeSpacing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.message.isFriendRequest) {
|
|
|
|
|
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
|
|
|
|
cellSize.height += [LKFriendRequestView calculateHeightWithMessage:self.message conversationStyle:self.conversationStyle];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -468,7 +468,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
{
|
|
|
|
|
OWSAssertDebug(self.delegate);
|
|
|
|
|
|
|
|
|
|
if (self.message.isFriendRequest) {
|
|
|
|
|
if ([self shouldShowFriendRequestUIForMessage:self.message]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -530,6 +530,35 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
return location.y <= headerBottom.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Convenience
|
|
|
|
|
|
|
|
|
|
- (BOOL)shouldShowFriendRequestUIForMessage:(TSMessage *)message
|
|
|
|
|
{
|
|
|
|
|
if ([message isKindOfClass:TSOutgoingMessage.class]) {
|
|
|
|
|
return message.isFriendRequest;
|
|
|
|
|
} else {
|
|
|
|
|
if (message.isFriendRequest) {
|
|
|
|
|
// Only show an incoming friend request if the user isn't yet friends with any of the other user's devices
|
|
|
|
|
NSString *senderID = ((TSIncomingMessage *)message).authorId;
|
|
|
|
|
NSMutableSet<TSContactThread *> *threads = [NSMutableSet new];
|
|
|
|
|
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
NSSet<LKDeviceLink *> *deviceLinks = [LKDatabaseUtilities getDeviceLinksFor:senderID in:transaction];
|
|
|
|
|
for (LKDeviceLink *deviceLink in deviceLinks) {
|
|
|
|
|
[threads addObject:[TSContactThread getThreadWithContactId:deviceLink.master.hexEncodedPublicKey transaction:transaction]];
|
|
|
|
|
[threads addObject:[TSContactThread getThreadWithContactId:deviceLink.slave.hexEncodedPublicKey transaction:transaction]];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
BOOL isFriend = [threads contains:^BOOL(NSObject *object) {
|
|
|
|
|
TSContactThread *thread = (TSContactThread *)object;
|
|
|
|
|
return thread.isContactFriend;
|
|
|
|
|
}];
|
|
|
|
|
return !isFriend;
|
|
|
|
|
} else {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
|