potentially fix the closed group not receiving messages issue

This commit is contained in:
ryanzhao 2021-08-20 10:01:25 +10:00
parent 1822c7df16
commit 7a354fe220
1 changed files with 5 additions and 2 deletions

View File

@ -40,8 +40,11 @@ public final class ClosedGroupPoller : NSObject {
public func startPolling(for groupPublicKey: String) {
guard !isPolling(for: groupPublicKey) else { return }
setUpPolling(for: groupPublicKey)
// Might be a race condition that the setUpPolling finishes too soon,
// and the timer is not created, if we mark the group as is polling
// after setUpPolling. So the poller may not work, thus misses messages.
isPolling[groupPublicKey] = true
setUpPolling(for: groupPublicKey)
}
@objc public func stop() {
@ -51,8 +54,8 @@ public final class ClosedGroupPoller : NSObject {
}
public func stopPolling(for groupPublicKey: String) {
timers[groupPublicKey]?.invalidate()
isPolling[groupPublicKey] = false
timers[groupPublicKey]?.invalidate()
}
// MARK: Private API