Merge branch 'database-refactor' into emoji-reacts

This commit is contained in:
Ryan Zhao 2022-08-08 15:00:00 +10:00
commit aaf91c3327
3 changed files with 8 additions and 14 deletions

View File

@ -521,7 +521,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
poller.stop()
}
ClosedGroupPoller.shared.stop()
ClosedGroupPoller.shared.stopAllPollers()
OpenGroupManager.shared.stopPolling()
}

View File

@ -501,7 +501,7 @@ public final class OpenGroupManager: NSObject {
let sortedMessages: [OpenGroupAPI.Message] = messages
.filter { $0.deleted != true }
.sorted { lhs, rhs in lhs.id < rhs.id }
let messageServerIdsToRemove: [Int64] = messages
var messageServerIdsToRemove: [Int64] = messages
.filter { $0.deleted == true }
.map { $0.id }
let seqNo: Int64? = sortedMessages.map { $0.seqNo }.max()

View File

@ -65,18 +65,12 @@ public final class ClosedGroupPoller {
setUpPolling(for: groupPublicKey)
}
@objc public func stop() {
Storage.shared
.read { db in
try ClosedGroup
.select(.threadId)
.asRequest(of: String.self)
.fetchAll(db)
}
.defaulting(to: [])
.forEach { [weak self] groupPublicKey in
self?.stopPolling(for: groupPublicKey)
}
public func stopAllPollers() {
let pollers: [String] = Array(isPolling.wrappedValue.keys)
pollers.forEach { groupPublicKey in
self.stopPolling(for: groupPublicKey)
}
}
public func stopPolling(for groupPublicKey: String) {