Preload device links to make message sending quicker

pull/220/head
nielsandriesse 4 years ago
parent 28f066b059
commit 17398f3f9e

@ -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<String> = []
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()
}

@ -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 {

Loading…
Cancel
Save