Fixed build errors and mock data tweaks

Fixed a couple of merge build errors
Made some tweaks to the MockDataGenerator to more-properly create open groups
Added some progress logging to the MockDataGenerator
Updated the MockDataGenerator to support generating threads with a fixed number of messages (ie. to compare performance based on message count)
pull/592/head
Morgan Pretty 3 years ago
parent 3e0ccaea4c
commit a39afd6037

@ -495,14 +495,20 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
// interacted with old UI which had cached the old value) // interacted with old UI which had cached the old value)
// //
// By using an equality check on the interaction we avoid this odd behaviour // By using an equality check on the interaction we avoid this odd behaviour
guard let index = viewItems.firstIndex(where: { $0.interaction == viewItem.interaction }), guard
let index = viewItems.firstIndex(where: { $0.interaction == viewItem.interaction }),
let cell = messagesTableView.cellForRow(at: IndexPath(row: index, section: 0)) as? VisibleMessageCell, let cell = messagesTableView.cellForRow(at: IndexPath(row: index, section: 0)) as? VisibleMessageCell,
let snapshot = cell.bubbleView.snapshotView(afterScreenUpdates: false), contextMenuWindow == nil, let snapshot = cell.bubbleView.snapshotView(afterScreenUpdates: false),
!ContextMenuVC.actions(for: viewItem, delegate: self).isEmpty else { return } contextMenuWindow == nil,
!ContextMenuVC.actions(for: viewItem, delegate: self).isEmpty,
let keyWindow: UIWindow = UIApplication.shared.keyWindow
else {
return
}
// Show the context menu if applicable // Show the context menu if applicable
UIImpactFeedbackGenerator(style: .heavy).impactOccurred() UIImpactFeedbackGenerator(style: .heavy).impactOccurred()
let frame = cell.convert(cell.bubbleView.frame, to: UIApplication.shared.keyWindow!) let frame = cell.convert(cell.bubbleView.frame, to: keyWindow)
let window = ContextMenuWindow() let window = ContextMenuWindow()
let contextMenuVC = ContextMenuVC(snapshot: snapshot, viewItem: viewItem, frame: frame, delegate: self) { [weak self] in let contextMenuVC = ContextMenuVC(snapshot: snapshot, viewItem: viewItem, frame: frame, delegate: self) { [weak self] in
window.isHidden = true window.isHidden = true

@ -66,15 +66,23 @@ enum MockDataGenerator {
} }
} }
// MARK: - Generation
static var printProgress: Bool = false
static var hasStartedGenerationThisRun: Bool = false
static func generateMockData() { static func generateMockData() {
// Don't re-generate the mock data if it already exists // Don't re-generate the mock data if it already exists
var existingMockDataThread: TSContactThread? var existingMockDataThread: TSContactThread?
Storage.read { transaction in Storage.read { transaction in
existingMockDataThread = TSContactThread.getWithContactSessionID("MockDatabaseThread", transaction: transaction) existingMockDataThread = TSContactThread.getWithContactSessionID("MockDatabaseThread", transaction: transaction)
} }
guard existingMockDataThread == nil else { return } guard !hasStartedGenerationThisRun && existingMockDataThread == nil else {
hasStartedGenerationThisRun = true
return
}
/// The mock data generation is quite slow, there are 3 parts which take a decent amount of time (deleting the account afterwards will also take a long time): /// The mock data generation is quite slow, there are 3 parts which take a decent amount of time (deleting the account afterwards will also take a long time):
/// Generating the threads & content - ~3s per 100 /// Generating the threads & content - ~3s per 100
@ -83,33 +91,48 @@ enum MockDataGenerator {
let dmThreadCount: Int = 100 let dmThreadCount: Int = 100
let closedGroupThreadCount: Int = 0 let closedGroupThreadCount: Int = 0
let openGroupThreadCount: Int = 0 let openGroupThreadCount: Int = 0
let maxMessagesPerThread: Int = 50 let messageRangePerThread: [ClosedRange<Int>] = [(0...50)]
let dmRandomSeed: Int = 1111 let dmRandomSeed: Int = 1111
let cgRandomSeed: Int = 2222 let cgRandomSeed: Int = 2222
let ogRandomSeed: Int = 3333 let ogRandomSeed: Int = 3333
let openGroupBaseUrl: String = "https://chat.lokinet.dev"
let logProgress: (String, String) -> () = { title, event in
guard printProgress else { return }
print("[MockDataGenerator] (\(Date().timeIntervalSince1970)) \(title) - \(event)")
}
hasStartedGenerationThisRun = true
// FIXME: Make sure this data doesn't go off device somehow? // FIXME: Make sure this data doesn't go off device somehow?
Storage.shared.write { anyTransaction in Storage.shared.write { anyTransaction in
guard let transaction: YapDatabaseReadWriteTransaction = anyTransaction as? YapDatabaseReadWriteTransaction else { return } guard let transaction: YapDatabaseReadWriteTransaction = anyTransaction as? YapDatabaseReadWriteTransaction else {
return
}
// First create the thread used to indicate that the mock data has been generated // First create the thread used to indicate that the mock data has been generated
logProgress("", "Start")
_ = TSContactThread.getOrCreateThread(withContactSessionID: "MockDatabaseThread", transaction: transaction) _ = TSContactThread.getOrCreateThread(withContactSessionID: "MockDatabaseThread", transaction: transaction)
// Multiple spaces to make it look more like words // Multiple spaces to make it look more like words
let stringContent: [String] = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 ".map { String($0) } let stringContent: [String] = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 ".map { String($0) }
let wordContent: [String] = ["alias", "consequatur", "aut", "perferendis", "sit", "voluptatem", "accusantium", "doloremque", "aperiam", "eaque", "ipsa", "quae", "ab", "illo", "inventore", "veritatis", "et", "quasi", "architecto", "beatae", "vitae", "dicta", "sunt", "explicabo", "aspernatur", "aut", "odit", "aut", "fugit", "sed", "quia", "consequuntur", "magni", "dolores", "eos", "qui", "ratione", "voluptatem", "sequi", "nesciunt", "neque", "dolorem", "ipsum", "quia", "dolor", "sit", "amet", "consectetur", "adipisci", "velit", "sed", "quia", "non", "numquam", "eius", "modi", "tempora", "incidunt", "ut", "labore", "et", "dolore", "magnam", "aliquam", "quaerat", "voluptatem", "ut", "enim", "ad", "minima", "veniam", "quis", "nostrum", "exercitationem", "ullam", "corporis", "nemo", "enim", "ipsam", "voluptatem", "quia", "voluptas", "sit", "suscipit", "laboriosam", "nisi", "ut", "aliquid", "ex", "ea", "commodi", "consequatur", "quis", "autem", "vel", "eum", "iure", "reprehenderit", "qui", "in", "ea", "voluptate", "velit", "esse", "quam", "nihil", "molestiae", "et", "iusto", "odio", "dignissimos", "ducimus", "qui", "blanditiis", "praesentium", "laudantium", "totam", "rem", "voluptatum", "deleniti", "atque", "corrupti", "quos", "dolores", "et", "quas", "molestias", "excepturi", "sint", "occaecati", "cupiditate", "non", "provident", "sed", "ut", "perspiciatis", "unde", "omnis", "iste", "natus", "error", "similique", "sunt", "in", "culpa", "qui", "officia", "deserunt", "mollitia", "animi", "id", "est", "laborum", "et", "dolorum", "fuga", "et", "harum", "quidem", "rerum", "facilis", "est", "et", "expedita", "distinctio", "nam", "libero", "tempore", "cum", "soluta", "nobis", "est", "eligendi", "optio", "cumque", "nihil", "impedit", "quo", "porro", "quisquam", "est", "qui", "minus", "id", "quod", "maxime", "placeat", "facere", "possimus", "omnis", "voluptas", "assumenda", "est", "omnis", "dolor", "repellendus", "temporibus", "autem", "quibusdam", "et", "aut", "consequatur", "vel", "illum", "qui", "dolorem", "eum", "fugiat", "quo", "voluptas", "nulla", "pariatur", "at", "vero", "eos", "et", "accusamus", "officiis", "debitis", "aut", "rerum", "necessitatibus", "saepe", "eveniet", "ut", "et", "voluptates", "repudiandae", "sint", "et", "molestiae", "non", "recusandae", "itaque", "earum", "rerum", "hic", "tenetur", "a", "sapiente", "delectus", "ut", "aut", "reiciendis", "voluptatibus", "maiores", "doloribus", "asperiores", "repellat"]
let timestampNow: TimeInterval = Date().timeIntervalSince1970 let timestampNow: TimeInterval = Date().timeIntervalSince1970
let userSessionId: String = getUserHexEncodedPublicKey() let userSessionId: String = getUserHexEncodedPublicKey()
// MARK: - -- DM Thread // MARK: - -- DM Thread
var dmThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: dmRandomSeed) var dmThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: dmRandomSeed)
logProgress("DM Threads", "Start Generating \(dmThreadCount) threads")
(0..<dmThreadCount).forEach { threadIndex in (0..<dmThreadCount).forEach { threadIndex in
let data = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &dmThreadRandomGenerator) }) logProgress("DM Thread \(threadIndex)", "Start")
let data = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &dmThreadRandomGenerator) })
let randomSessionId: String = KeyPairUtilities.generate(from: data).x25519KeyPair.hexEncodedPublicKey let randomSessionId: String = KeyPairUtilities.generate(from: data).x25519KeyPair.hexEncodedPublicKey
let isMessageRequest: Bool = Bool.random(using: &dmThreadRandomGenerator) let isMessageRequest: Bool = Bool.random(using: &dmThreadRandomGenerator)
let contactNameLength: Int = ((5..<20).randomElement(using: &dmThreadRandomGenerator) ?? 0) let contactNameLength: Int = ((5..<20).randomElement(using: &dmThreadRandomGenerator) ?? 0)
let numMessages: Int = ((0..<maxMessagesPerThread).randomElement(using: &dmThreadRandomGenerator) ?? 0) let numMessages: Int = (messageRangePerThread[threadIndex % messageRangePerThread.count]
.randomElement(using: &dmThreadRandomGenerator) ?? 0)
// Generate the thread // Generate the thread
let thread: TSContactThread = TSContactThread.getOrCreateThread(withContactSessionID: randomSessionId, transaction: transaction) let thread: TSContactThread = TSContactThread.getOrCreateThread(withContactSessionID: randomSessionId, transaction: transaction)
@ -121,23 +144,27 @@ enum MockDataGenerator {
.compactMap { _ in stringContent.randomElement(using: &dmThreadRandomGenerator) } .compactMap { _ in stringContent.randomElement(using: &dmThreadRandomGenerator) }
.joined() .joined()
contact.isApproved = (!isMessageRequest || Bool.random(using: &dmThreadRandomGenerator)) contact.isApproved = (!isMessageRequest || Bool.random(using: &dmThreadRandomGenerator))
contact.didApproveMe = (!isMessageRequest && Bool.random(using: &dmThreadRandomGenerator)) contact.didApproveMe = (
!isMessageRequest &&
(((0..<10).randomElement(using: &dmThreadRandomGenerator) ?? 0) < 8) // 80% approved the current user
)
Storage.shared.setContact(contact, using: transaction) Storage.shared.setContact(contact, using: transaction)
// Generate the message history (Note: Unapproved message requests will only include incoming messages) // Generate the message history (Note: Unapproved message requests will only include incoming messages)
logProgress("DM Thread \(threadIndex)", "Generate \(numMessages) Messages")
(0..<numMessages).forEach { index in (0..<numMessages).forEach { index in
let isIncoming: Bool = ( let isIncoming: Bool = (
Bool.random(using: &dmThreadRandomGenerator) && Bool.random(using: &dmThreadRandomGenerator) &&
(!isMessageRequest || contact.isApproved) (!isMessageRequest || contact.isApproved)
) )
let messageLength: Int = ((3..<40).randomElement(using: &dmThreadRandomGenerator) ?? 0) let messageWords: Int = ((1..<20).randomElement(using: &dmThreadRandomGenerator) ?? 0)
let message: VisibleMessage = VisibleMessage() let message: VisibleMessage = VisibleMessage()
message.sender = (isIncoming ? randomSessionId : userSessionId) message.sender = (isIncoming ? randomSessionId : userSessionId)
message.sentTimestamp = UInt64(floor(timestampNow - Double(index * 5))) message.sentTimestamp = UInt64(floor(timestampNow - Double(index * 5)) * 1000)
message.text = (0..<messageLength) message.text = (0..<messageWords)
.compactMap { _ in stringContent.randomElement(using: &dmThreadRandomGenerator) } .compactMap { _ in wordContent.randomElement(using: &dmThreadRandomGenerator) }
.joined() .joined(separator: " ")
if isIncoming { if isIncoming {
let tsMessage: TSOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction) let tsMessage: TSOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction)
@ -151,23 +178,30 @@ enum MockDataGenerator {
// Save the thread // Save the thread
thread.save(with: transaction) thread.save(with: transaction)
logProgress("DM Thread \(threadIndex)", "Done")
} }
logProgress("DM Threads", "Done")
// MARK: - -- Closed Group // MARK: - -- Closed Group
var cgThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: cgRandomSeed) var cgThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: cgRandomSeed)
logProgress("Closed Group Threads", "Start Generating \(closedGroupThreadCount) threads")
(0..<closedGroupThreadCount).forEach { threadIndex in (0..<closedGroupThreadCount).forEach { threadIndex in
logProgress("Closed Group Thread \(threadIndex)", "Start")
let data = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &cgThreadRandomGenerator) }) let data = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &cgThreadRandomGenerator) })
let randomGroupPublicKey: String = KeyPairUtilities.generate(from: data).x25519KeyPair.hexEncodedPublicKey let randomGroupPublicKey: String = KeyPairUtilities.generate(from: data).x25519KeyPair.hexEncodedPublicKey
let groupNameLength: Int = ((5..<20).randomElement(using: &cgThreadRandomGenerator) ?? 0) let groupNameLength: Int = ((5..<20).randomElement(using: &cgThreadRandomGenerator) ?? 0)
let groupName: String = (0..<groupNameLength) let groupName: String = (0..<groupNameLength)
.compactMap { _ in stringContent.randomElement(using: &cgThreadRandomGenerator) } .compactMap { _ in stringContent.randomElement(using: &cgThreadRandomGenerator) }
.joined() .joined()
let numGroupMembers: Int = ((0..<5).randomElement(using: &cgThreadRandomGenerator) ?? 0) let numGroupMembers: Int = ((0..<10).randomElement(using: &cgThreadRandomGenerator) ?? 0)
let numMessages: Int = ((0..<maxMessagesPerThread).randomElement(using: &cgThreadRandomGenerator) ?? 0) let numMessages: Int = (messageRangePerThread[threadIndex % messageRangePerThread.count]
.randomElement(using: &cgThreadRandomGenerator) ?? 0)
// Generate the Contacts in the group // Generate the Contacts in the group
var members: [String] = [userSessionId] var members: [String] = [userSessionId]
logProgress("Closed Group Thread \(threadIndex)", "Generate \(numGroupMembers) Contacts")
(0..<numGroupMembers).forEach { _ in (0..<numGroupMembers).forEach { _ in
let contactData = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &cgThreadRandomGenerator) }) let contactData = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &cgThreadRandomGenerator) })
@ -202,14 +236,16 @@ enum MockDataGenerator {
Storage.shared.addClosedGroupEncryptionKeyPair(encryptionKeyPair, for: randomGroupPublicKey, using: transaction) Storage.shared.addClosedGroupEncryptionKeyPair(encryptionKeyPair, for: randomGroupPublicKey, using: transaction)
// Generate the message history (Note: Unapproved message requests will only include incoming messages) // Generate the message history (Note: Unapproved message requests will only include incoming messages)
logProgress("Closed Group Thread \(threadIndex)", "Generate \(numMessages) Messages")
(0..<numMessages).forEach { index in (0..<numMessages).forEach { index in
let messageLength: Int = ((3..<40).randomElement(using: &dmThreadRandomGenerator) ?? 0) let messageWords: Int = ((1..<20).randomElement(using: &cgThreadRandomGenerator) ?? 0)
let message: VisibleMessage = VisibleMessage() let message: VisibleMessage = VisibleMessage()
message.sender = (members.randomElement(using: &cgThreadRandomGenerator) ?? userSessionId) message.sender = (members.randomElement(using: &cgThreadRandomGenerator) ?? userSessionId)
message.sentTimestamp = UInt64(floor(timestampNow - Double(index * 5))) message.sentTimestamp = UInt64(floor(timestampNow - Double(index * 5)) * 1000)
message.text = (0..<messageLength) message.text = (0..<messageWords)
.compactMap { _ in stringContent.randomElement(using: &dmThreadRandomGenerator) } .compactMap { _ in wordContent.randomElement(using: &cgThreadRandomGenerator) }
.joined() .joined(separator: " ")
if message.sender != userSessionId { if message.sender != userSessionId {
let tsMessage: TSOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction) let tsMessage: TSOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction)
@ -223,14 +259,18 @@ enum MockDataGenerator {
// Save the thread // Save the thread
thread.save(with: transaction) thread.save(with: transaction)
logProgress("Closed Group Thread \(threadIndex)", "Done")
} }
logProgress("Closed Group Threads", "Done")
// MARK: - --Open Group // MARK: - --Open Group
var ogThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: ogRandomSeed) var ogThreadRandomGenerator: ARC4RandomNumberGenerator = ARC4RandomNumberGenerator(seed: ogRandomSeed)
logProgress("Open Group Threads", "Start Generating \(openGroupThreadCount) threads")
(0..<openGroupThreadCount).forEach { threadIndex in (0..<openGroupThreadCount).forEach { threadIndex in
let data = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &ogThreadRandomGenerator) }) logProgress("Open Group Thread \(threadIndex)", "Start")
let randomGroupPublicKey: String = KeyPairUtilities.generate(from: data).x25519KeyPair.hexEncodedPublicKey
let randomGroupPublicKey: String = ((0..<32).map { _ in UInt8.random(in: UInt8.min...UInt8.max, using: &dmThreadRandomGenerator) }).toHexString()
let serverNameLength: Int = ((5..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0) let serverNameLength: Int = ((5..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0)
let roomNameLength: Int = ((5..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0) let roomNameLength: Int = ((5..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0)
let groupDescriptionLength: Int = ((10..<50).randomElement(using: &ogThreadRandomGenerator) ?? 0) let groupDescriptionLength: Int = ((10..<50).randomElement(using: &ogThreadRandomGenerator) ?? 0)
@ -243,11 +283,31 @@ enum MockDataGenerator {
let groupDescription: String = (0..<groupDescriptionLength) let groupDescription: String = (0..<groupDescriptionLength)
.compactMap { _ in stringContent.randomElement(using: &ogThreadRandomGenerator) } .compactMap { _ in stringContent.randomElement(using: &ogThreadRandomGenerator) }
.joined() .joined()
let numGroupMembers: Int = ((0..<250).randomElement(using: &ogThreadRandomGenerator) ?? 0)
let numMessages: Int = (messageRangePerThread[threadIndex % messageRangePerThread.count]
.randomElement(using: &ogThreadRandomGenerator) ?? 0)
// Generate the Contacts in the group
var members: [String] = [userSessionId]
logProgress("Open Group Thread \(threadIndex)", "Generate \(numGroupMembers) Contacts")
(0..<numGroupMembers).forEach { _ in
let contactData = Data((0..<16).map { _ in UInt8.random(in: (UInt8.min...UInt8.max), using: &ogThreadRandomGenerator) })
let randomSessionId: String = KeyPairUtilities.generate(from: contactData).x25519KeyPair.hexEncodedPublicKey
let contactNameLength: Int = ((5..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0)
let contact = Contact(sessionID: randomSessionId)
contact.name = (0..<contactNameLength)
.compactMap { _ in stringContent.randomElement(using: &ogThreadRandomGenerator) }
.joined()
Storage.shared.setContact(contact, using: transaction)
members.append(randomSessionId)
}
// Create the open group model and the thread // Create the open group model and the thread
let openGroup: OpenGroup = OpenGroup( let openGroup: OpenGroup = OpenGroup(
server: serverName, server: openGroupBaseUrl,
room: roomName, room: "MockData_\(roomName)",
publicKey: randomGroupPublicKey, publicKey: randomGroupPublicKey,
name: roomName, name: roomName,
groupDescription: groupDescription, groupDescription: groupDescription,
@ -255,7 +315,7 @@ enum MockDataGenerator {
infoUpdates: 0 infoUpdates: 0
) )
let groupId: Data = LKGroupUtilities.getEncodedOpenGroupIDAsData(openGroup.id) let groupId: Data = LKGroupUtilities.getEncodedOpenGroupIDAsData(openGroup.id)
let model = TSGroupModel(title: openGroup.name, memberIds: [ userSessionId ], image: nil, groupId: groupId, groupType: .openGroup, adminIds: [], moderatorIds: []) let model = TSGroupModel(title: openGroup.name, memberIds: members, image: nil, groupId: groupId, groupType: .openGroup, adminIds: [], moderatorIds: [])
let thread = TSGroupThread.getOrCreateThread(with: model, transaction: transaction) let thread = TSGroupThread.getOrCreateThread(with: model, transaction: transaction)
thread.shouldBeVisible = true thread.shouldBeVisible = true
@ -276,7 +336,34 @@ enum MockDataGenerator {
) )
Storage.shared.setOpenGroupServer(server, using: transaction) Storage.shared.setOpenGroupServer(server, using: transaction)
// Generate the message history (Note: Unapproved message requests will only include incoming messages)
logProgress("Open Group Thread \(threadIndex)", "Generate \(numMessages) Messages")
(0..<numMessages).forEach { index in
let messageWords: Int = ((1..<20).randomElement(using: &ogThreadRandomGenerator) ?? 0)
let message: VisibleMessage = VisibleMessage()
message.sender = (members.randomElement(using: &ogThreadRandomGenerator) ?? userSessionId)
message.sentTimestamp = UInt64(floor(timestampNow - Double(index * 5)) * 1000)
message.text = (0..<messageWords)
.compactMap { _ in wordContent.randomElement(using: &ogThreadRandomGenerator) }
.joined(separator: " ")
if message.sender != userSessionId {
let tsMessage: TSOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction)
tsMessage.save(with: transaction)
}
else {
let tsMessage: TSIncomingMessage = TSIncomingMessage.from(message, quotedMessage: nil, linkPreview: nil, associatedWith: thread)
tsMessage.save(with: transaction)
}
}
logProgress("Open Group Thread \(threadIndex)", "Done")
} }
logProgress("Open Group Threads", "Done")
logProgress("", "Complete")
} }
} }
} }

@ -175,9 +175,9 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
// MARK: Poll for open groups // MARK: Poll for open groups
private func pollForOpenGroups() -> [Promise<Void>] { private func pollForOpenGroups() -> [Promise<Void>] {
var promises: [Promise<Void>] = [] var promises: [Promise<Void>] = []
let servers = Set(Storage.shared.getAllV2OpenGroups().values.map { $0.server }) let servers = Set(Storage.shared.getAllOpenGroups().values.map { $0.server })
servers.forEach { server in servers.forEach { server in
let poller = OpenGroupPollerV2(for: server) let poller = OpenGroupAPI.Poller(for: server)
let promise = poller.poll().timeout(seconds: 20, timeoutError: NotificationServiceError.timeout) let promise = poller.poll().timeout(seconds: 20, timeoutError: NotificationServiceError.timeout)
promises.append(promise) promises.append(promise)
} }

Loading…
Cancel
Save