From f00b1ea21b22de192d074a02aa218ac83894e03f Mon Sep 17 00:00:00 2001 From: Peter <> Date: Fri, 11 Oct 2019 16:23:02 +0400 Subject: [PATCH] Add postbox transaction guard --- submodules/TelegramUI/TelegramUI/SharedWakeupManager.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/submodules/TelegramUI/TelegramUI/SharedWakeupManager.swift b/submodules/TelegramUI/TelegramUI/SharedWakeupManager.swift index e6d31125b9..2abd8eed61 100644 --- a/submodules/TelegramUI/TelegramUI/SharedWakeupManager.swift +++ b/submodules/TelegramUI/TelegramUI/SharedWakeupManager.swift @@ -324,6 +324,8 @@ public final class SharedWakeupManager { private func updateAccounts(hasTasks: Bool) { if self.inForeground || self.hasActiveAudioSession || self.isInBackgroundExtension || (hasTasks && self.currentExternalCompletion != nil) || self.activeExplicitExtensionTimer != nil { for (account, primary, tasks) in self.accountsAndTasks { + account.postbox.setCanBeginTransactions(true) + if (self.inForeground && primary) || !tasks.isEmpty || (self.activeExplicitExtensionTimer != nil && primary) { account.shouldBeServiceTaskMaster.set(.single(.always)) } else { @@ -335,6 +337,7 @@ public final class SharedWakeupManager { } } else { for (account, _, _) in self.accountsAndTasks { + account.postbox.setCanBeginTransactions(false) account.shouldBeServiceTaskMaster.set(.single(.never)) account.shouldKeepOnlinePresence.set(.single(false)) account.shouldKeepBackgroundDownloadConnections.set(.single(false))