diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index c98a124f6..7fa304f00 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -181,8 +181,8 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou self.view.addSubview(bottomContainer) bottomContainer.autoPinWidthToSuperview() - bottomContainer.autoPinEdge(toSuperviewEdge: .bottom) - footerBar.autoPinEdge(.bottom, to: .bottom, of: view) + bottomContainer.autoPinEdge(toSuperviewSafeArea: .bottom) + footerBar.autoPinEdge(toSuperviewSafeArea: .bottom) footerBar.autoSetDimension(.height, toSize: 44) updateTitle() diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 5cb47adfa..37c94e19f 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -1027,10 +1027,26 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error); - (nullable NSString *)profileNameForRecipientWithID:(NSString *)recipientID { + if ([self.tsAccountManager.localNumber isEqualToString:recipientID]) { + return self.localUserProfile.profileName; + } + + __block OWSUserProfile *userProfile; + + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + userProfile = [OWSUserProfile fetchObjectWithUniqueID:recipientID transaction:transaction]; + }]; + + if (userProfile != nil) { + return userProfile.profileName; + } + __block NSString *result; + [LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { result = [self profileNameForRecipientWithID:recipientID transaction:transaction]; } error:nil]; + return result; } diff --git a/SignalServiceKit/src/Loki/API/LokiAPI.swift b/SignalServiceKit/src/Loki/API/LokiAPI.swift index 452ee54c6..f2b422ab7 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPI.swift @@ -9,7 +9,6 @@ public final class LokiAPI : NSObject { // MARK: Settings private static let maxRetryCount: UInt = 4 private static let defaultTimeout: TimeInterval = 20 - private static let longPollingTimeout: TimeInterval = 40 internal static var powDifficulty: UInt = 1 /// - Note: Changing this on the fly is not recommended. @@ -51,19 +50,17 @@ public final class LokiAPI : NSObject { } } - internal static func getRawMessages(from target: LokiAPITarget, usingLongPolling useLongPolling: Bool) -> RawResponsePromise { + internal static func getRawMessages(from target: LokiAPITarget) -> RawResponsePromise { let lastHashValue = getLastMessageHashValue(for: target) ?? "" let parameters = [ "pubKey" : getUserHexEncodedPublicKey(), "lastHash" : lastHashValue ] - let headers: [String:String]? = useLongPolling ? [ "X-Loki-Long-Poll" : "true" ] : nil - let timeout: TimeInterval? = useLongPolling ? longPollingTimeout : nil - return invoke(.getMessages, on: target, associatedWith: getUserHexEncodedPublicKey(), parameters: parameters, headers: headers, timeout: timeout) + return invoke(.getMessages, on: target, associatedWith: getUserHexEncodedPublicKey(), parameters: parameters) } // MARK: Public API public static func getMessages() -> Promise> { return attempt(maxRetryCount: maxRetryCount, recoveringOn: LokiAPI.workQueue) { getTargetSnodes(for: getUserHexEncodedPublicKey()).mapValues2 { targetSnode in - getRawMessages(from: targetSnode, usingLongPolling: false).map2 { parseRawMessagesResponse($0, from: targetSnode) } + getRawMessages(from: targetSnode).map2 { parseRawMessagesResponse($0, from: targetSnode) } }.map2 { Set($0) } } } diff --git a/SignalServiceKit/src/Loki/API/LokiPoller.swift b/SignalServiceKit/src/Loki/API/LokiPoller.swift index fac50bd68..2d24f3fcc 100644 --- a/SignalServiceKit/src/Loki/API/LokiPoller.swift +++ b/SignalServiceKit/src/Loki/API/LokiPoller.swift @@ -96,7 +96,7 @@ public final class LokiPoller : NSObject { private func poll(_ target: LokiAPITarget, seal longTermSeal: Resolver) -> Promise { guard !hasStopped else { return Promise { $0.fulfill(()) } } - return LokiAPI.getRawMessages(from: target, usingLongPolling: false).then(on: DispatchQueue.main) { [weak self] rawResponse -> Promise in + return LokiAPI.getRawMessages(from: target).then(on: DispatchQueue.main) { [weak self] rawResponse -> Promise in guard let strongSelf = self, !strongSelf.hasStopped else { return Promise { $0.fulfill(()) } } let messages = LokiAPI.parseRawMessagesResponse(rawResponse, from: target) strongSelf.onMessagesReceived(messages) diff --git a/SignalServiceKit/src/Loki/Protocol/Mentions/MentionsManager.swift b/SignalServiceKit/src/Loki/Protocol/Mentions/MentionsManager.swift index 5f3c9ca61..fc954c535 100644 --- a/SignalServiceKit/src/Loki/Protocol/Mentions/MentionsManager.swift +++ b/SignalServiceKit/src/Loki/Protocol/Mentions/MentionsManager.swift @@ -85,6 +85,8 @@ public final class MentionsManager : NSObject { populate(in: transaction) } } - userPublicKeyCache[threadID] = result + if !result.isEmpty { + userPublicKeyCache[threadID] = result + } } }