From 73eeff3ea1a5758c13b6d41e0ec97d44c8da51ac Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 12 May 2021 10:40:42 +1000 Subject: [PATCH] Debug --- .../Pollers/ClosedGroupPoller.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift index b066cd300..2765b541a 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift @@ -58,10 +58,14 @@ public final class ClosedGroupPoller : NSObject { // MARK: Private API private func setUpPolling(for groupPublicKey: String) { poll(groupPublicKey).done2 { [weak self] _ in - self?.pollRecursively(groupPublicKey) + DispatchQueue.main.async { // Timers don't do well on background queues + self?.pollRecursively(groupPublicKey) + } }.catch2 { [weak self] error in - // The error is logged in poll(_:isBackgroundPoll:) - self?.pollRecursively(groupPublicKey) + // The error is logged in poll(_:) + DispatchQueue.main.async { // Timers don't do well on background queues + self?.pollRecursively(groupPublicKey) + } } } @@ -82,10 +86,14 @@ public final class ClosedGroupPoller : NSObject { timers[groupPublicKey] = Timer.scheduledTimer(withTimeInterval: nextPollInterval, repeats: false) { [weak self] timer in timer.invalidate() self?.poll(groupPublicKey).done2 { _ in - self?.pollRecursively(groupPublicKey) + DispatchQueue.main.async { // Timers don't do well on background queues + self?.pollRecursively(groupPublicKey) + } }.catch2 { error in // The error is logged in poll(_:) - self?.pollRecursively(groupPublicKey) + DispatchQueue.main.async { // Timers don't do well on background queues + self?.pollRecursively(groupPublicKey) + } } } }