diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 4d6205f0e..509027d34 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -554,14 +554,13 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate, backgroundTask = backgroundTaskService.startBackgroundTask(withName: "SuspendApp: \(UUID().uuidString)") { [weak self] in guard let self else { return } - userSession?.clientProxy.stopSync { - // No need to weakify self, this is a non escaping closure - self.backgroundTask?.stop() - self.backgroundTask = nil - - self.backgroundAppRefreshTask?.setTaskCompleted(success: true) - self.backgroundAppRefreshTask = nil - } + userSession?.clientProxy.stopSync() + + backgroundTask?.stop() + backgroundTask = nil + + backgroundAppRefreshTask?.setTaskCompleted(success: true) + backgroundAppRefreshTask = nil } isSuspended = true diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 45f68d262..91a4726ac 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -166,19 +166,9 @@ class ClientProxy: ClientProxyProtocol { slidingSyncObserverToken = slidingSync?.sync() } - func stopSync(completionHandler: () -> Void) { - guard let slidingSyncObserverToken else { - MXLog.info("No sync is present") - return - } - stopSync() - while !slidingSyncObserverToken.isFinished() { } - completionHandler() - } - func stopSync() { MXLog.info("Stopping sync") - slidingSyncObserverToken?.cancel() + slidingSync?.stopSync() slidingSyncObserverToken = nil } diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 3b4f8f542..3c13e8aa5 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -86,10 +86,6 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func startSync() - /// Stops the sync usiung non escaping closure. - /// It's supposed to be used for the expiration handlers to guarantee its synchronous execution - func stopSync(completionHandler: () -> Void) - func stopSync() func directRoomForUserID(_ userID: String) async -> Result