From 7a9f2202907bb1901debfe6921877c404336f8a3 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 16 Mar 2023 20:19:53 +0000 Subject: [PATCH] ios: do not suspend chat when switching to another callkit call (#2020) --- .../Shared/Views/Call/CallController.swift | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/ios/Shared/Views/Call/CallController.swift b/apps/ios/Shared/Views/Call/CallController.swift index 365580735c..83338804c1 100644 --- a/apps/ios/Shared/Views/Call/CallController.swift +++ b/apps/ios/Shared/Views/Call/CallController.swift @@ -124,21 +124,21 @@ class CallController: NSObject, CXProviderDelegate, PKPushRegistryDelegate, Obse print(error) logger.error("failed deactivating audio session") } - // Allows to accept second call while in call with a previous before suspending a chat, - // see `.onChange(of: scenePhase)` in SimpleXApp - DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in - if ChatModel.shared.activeCall == nil { - logger.debug("CallController: shouldSuspendChat \(String(describing: self?.shouldSuspendChat), privacy: .public)") - self?.suspendOnEndCall() - } - } + suspendOnEndCall() } func suspendOnEndCall() { if shouldSuspendChat { - shouldSuspendChat = false - suspendChat() - BGManager.shared.schedule() + // The delay allows to accept the second call before suspending a chat + // see `.onChange(of: scenePhase)` in SimpleXApp + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in + logger.debug("CallController: shouldSuspendChat \(String(describing: self?.shouldSuspendChat), privacy: .public)") + if ChatModel.shared.activeCall == nil && self?.shouldSuspendChat == true { + self?.shouldSuspendChat = false + suspendChat() + BGManager.shared.schedule() + } + } } }