From b8f71c5c28a89685e4644852551b42263ed0781e Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 30 Jan 2020 14:20:51 +1100 Subject: [PATCH] Fix multi device --- Signal/src/Loki/Components/FakeChatView.swift | 4 +- .../View Controllers/DeviceLinkingModal.swift | 2 +- .../src/Messages/OWSMessageManager.m | 1 - .../src/Messages/OWSMessageSender.m | 44 ++----------------- 4 files changed, 6 insertions(+), 45 deletions(-) diff --git a/Signal/src/Loki/Components/FakeChatView.swift b/Signal/src/Loki/Components/FakeChatView.swift index 564d9e711..14997b9d1 100644 --- a/Signal/src/Loki/Components/FakeChatView.swift +++ b/Signal/src/Loki/Components/FakeChatView.swift @@ -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() diff --git a/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift b/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift index fabb023e5..898f11432 100644 --- a/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift +++ b/Signal/src/Loki/View Controllers/DeviceLinkingModal.swift @@ -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() diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 27e58ed17..881ad1fbb 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -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]; diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index 93c314f71..c6baf3029 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -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 *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];