diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift index 44b871382..41657725c 100644 --- a/Signal/src/Loki/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/View Controllers/HomeVC.swift @@ -154,6 +154,19 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol DispatchQueue.global(qos: .utility).async { let _ = IP2Country.shared.populateCacheIfNeeded() } + // Preload device links to make message sending quicker + var publicKeys: Set = [] + let storage = OWSPrimaryStorage.shared() + storage.dbReadConnection.read { transaction in + TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in + guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible && thread.isContactFriend else { return } + let publicKey = thread.contactIdentifier() + guard UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) != nil, + storage.getMasterHexEncodedPublicKey(for: publicKey, in: transaction) == nil else { return } + publicKeys.insert(publicKey) + } + } + let _ = LokiFileServerAPI.getDeviceLinks(associatedWith: publicKeys) // Do initial update reload() } diff --git a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift index 396f6b36c..ca997c483 100644 --- a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift +++ b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift @@ -11,9 +11,8 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat let hexEncodedPublicKey = thread.contactIdentifier() guard UserDisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) != nil else { return } // We shouldn't be able to add slave devices to groups - if (storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) == nil) { - result.append(hexEncodedPublicKey) - } + guard storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) == nil else { return } + result.append(hexEncodedPublicKey) } } func getDisplayName(for hexEncodedPublicKey: String) -> String {