mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Start using the new synchronous stopSync method
This commit is contained in:
committed by
Stefan Ceriu
parent
9c1c51645f
commit
caa4abe659
@@ -554,14 +554,13 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
|||||||
backgroundTask = backgroundTaskService.startBackgroundTask(withName: "SuspendApp: \(UUID().uuidString)") { [weak self] in
|
backgroundTask = backgroundTaskService.startBackgroundTask(withName: "SuspendApp: \(UUID().uuidString)") { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
userSession?.clientProxy.stopSync {
|
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)
|
backgroundTask?.stop()
|
||||||
self.backgroundAppRefreshTask = nil
|
backgroundTask = nil
|
||||||
}
|
|
||||||
|
backgroundAppRefreshTask?.setTaskCompleted(success: true)
|
||||||
|
backgroundAppRefreshTask = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
isSuspended = true
|
isSuspended = true
|
||||||
|
|||||||
@@ -166,19 +166,9 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
slidingSyncObserverToken = slidingSync?.sync()
|
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() {
|
func stopSync() {
|
||||||
MXLog.info("Stopping sync")
|
MXLog.info("Stopping sync")
|
||||||
slidingSyncObserverToken?.cancel()
|
slidingSync?.stopSync()
|
||||||
slidingSyncObserverToken = nil
|
slidingSyncObserverToken = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,10 +86,6 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
|||||||
|
|
||||||
func startSync()
|
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 stopSync()
|
||||||
|
|
||||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError>
|
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError>
|
||||||
|
|||||||
Reference in New Issue
Block a user