Fix multi device

pull/80/head
Niels Andriesse 5 years ago
parent cb67b7d596
commit b8f71c5c28

@ -54,8 +54,8 @@ final class FakeChatView : UIView {
bubbleView.set(.width, to: Values.fakeChatBubbleWidth)
bubbleView.layer.cornerRadius = Values.fakeChatBubbleCornerRadius
bubbleView.layer.shadowColor = UIColor.black.cgColor
bubbleView.layer.shadowRadius = 8
bubbleView.layer.shadowOpacity = 0.64
bubbleView.layer.shadowRadius = 2
bubbleView.layer.shadowOpacity = 0.24
let backgroundColor = wasSentByCurrentUser ? Colors.fakeChatBubbleBackground : Colors.accent
bubbleView.backgroundColor = backgroundColor
let label = UILabel()

@ -150,7 +150,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
// MARK: Device Linking
func requestUserAuthorization(for deviceLink: DeviceLink) {
self.deviceLink = deviceLink
qrCodeImageView.isHidden = true
qrCodeImageViewContainer.isHidden = true
titleLabel.text = NSLocalizedString("Linking Request Received", comment: "")
subtitleLabel.text = NSLocalizedString("Please check that the words below match those shown on your other device", comment: "")
let hexEncodedPublicKey = deviceLink.slave.hexEncodedPublicKey.removing05PrefixIfNeeded()

@ -1761,7 +1761,6 @@ NS_ASSUME_NONNULL_BEGIN
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:envelope.source transaction:transaction];
// We shouldn't be able to skip from none to friends under normal circumstances
if (thread.friendRequestStatus == LKThreadFriendRequestStatusNone) { return; }
if (thread.isContactFriend) return;
// Become happy friends and go on great adventures
[thread saveFriendRequestStatus:LKThreadFriendRequestStatusFriends withTransaction:transaction];
TSOutgoingMessage *existingFriendRequestMessage = [thread.lastInteraction as:TSOutgoingMessage.class];

@ -950,6 +950,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// Force hide slave device thread
NSString *masterHexEncodedPublicKey = [LKDatabaseUtilities getMasterHexEncodedPublicKeyFor:hexEncodedPublicKey in:transaction];
thread.isForceHidden = masterHexEncodedPublicKey != nil && ![masterHexEncodedPublicKey isEqualToString:hexEncodedPublicKey];
if (thread.friendRequestStatus == LKThreadFriendRequestStatusNone || thread.friendRequestStatus == LKThreadFriendRequestStatusRequestExpired) {
[thread saveFriendRequestStatus:LKThreadFriendRequestStatusRequestSent withTransaction:transaction];
}
[thread saveWithTransaction:transaction];
}];
LKFriendRequestMessage *message = [[LKFriendRequestMessage alloc] initOutgoingMessageWithTimestamp:NSDate.ows_millisecondTimeStamp inThread:thread messageBody:@"Please accept to enable messages to be synced across devices" attachmentIds:[NSMutableArray new]
@ -978,47 +981,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
BOOL isDeviceLinkMessage = [message isKindOfClass:LKDeviceLinkMessage.class];
if (isPublicChatMessage || isDeviceLinkMessage) {
[self sendMessage:messageSend];
} else if (isGroupMessage) {
[self sendMessage:messageSend];
// TODO: Multi device?
// [[LKAPI getDestinationsFor:contactID]
// .thenOn(OWSDispatch.sendingQueue, ^(NSArray<LKDestination *> *destinations) {
// // Get master destination
// LKDestination *masterDestination = [destinations filtered:^BOOL(LKDestination *destination) {
// return [destination.kind isEqual:@"master"];
// }].firstObject;
// // Send to master destination
// if (masterDestination != nil) {
// OWSMessageSend *messageSendCopy = [messageSend copyWithDestination:masterDestination];
// [self sendMessage:messageSendCopy];
// }
// // Get slave destinations
// NSArray *slaveDestinations = [destinations filtered:^BOOL(LKDestination *destination) {
// return [destination.kind isEqual:@"slave"];
// }];
// // Send to slave destinations (using a best attempt approach (i.e. ignoring the message send result) for now)
// __block BOOL hasSession;
// [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// for (LKDestination *slaveDestination in slaveDestinations) {
// hasSession = [self.primaryStorage containsSession:slaveDestination.hexEncodedPublicKey deviceId:1 protocolContext:transaction];
// if (hasSession) {
// OWSMessageSend *messageSendCopy = [messageSend copyWithDestination:slaveDestinations];
// [self sendMessage:messageSendCopy];
// }
// else {
// //RYAN TODO: If current device has no session with the slave device try to build a session with the slave device.
// OWSMessageSend *sessionRequestMessage = [self getMultiDeviceSessionRequestMessageForHexEncodedPublicKey:slaveDestination.hexEncodedPublicKey forThread:messageSend.thread];
// [self sendMessage:sessionRequestMessage];
// }
// }
//
// }];
// })
// .catchOn(OWSDispatch.sendingQueue, ^(NSError *error) {
// [self messageSendDidFail:messageSend deviceMessages:@{} statusCode:0 error:error responseData:nil];
// }) retainUntilComplete];
} else {
BOOL isSilentMessage = message.isSilent || [message isKindOfClass:LKEphemeralMessage.class] || [message isKindOfClass:OWSOutgoingSyncMessage.class];
BOOL isFriendRequestMessage = [message isKindOfClass:LKFriendRequestMessage.class];

Loading…
Cancel
Save