Fixed a crash and the SOGS deletion logic to continue to support the deprecated approach for the time being

Fixed an issue where the app could crash when entering the background during migration
Added the old 'messageServerIdsToRemove' code back for the time being to support the deprecated deletion behaviour
This commit is contained in:
Morgan Pretty 2022-08-08 13:56:11 +10:00
parent 3f63a44c31
commit 2025fd2638
3 changed files with 13 additions and 15 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()
@ -518,7 +518,11 @@ public final class OpenGroupManager: NSObject {
guard
let base64EncodedString: String = message.base64EncodedData,
let data = Data(base64Encoded: base64EncodedString)
else { return }
else {
// FIXME: Once the SOGS Emoji Reacts update is live we should remove this line (deprecated by the `deleted` flag)
messageServerIdsToRemove.append(Int64(message.id))
return
}
do {
let processedMessage: ProcessedMessage? = try Message.processReceivedOpenGroupMessage(

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