mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Cleanup the background task that pauses the SDK when resigning active (#903)
* checking if the stop taskHandle is finished before stopping the bg task * stopping the sync in background now works properly * this will prevent the case in which if the app suspends and then is immediately foregrounded again, we do not start the sync * now works as intended * code improvement * improved the code a bit
This commit is contained in:
@@ -152,16 +152,30 @@ class ClientProxy: ClientProxyProtocol {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var isSyncing: Bool {
|
||||
slidingSyncObserverToken != nil
|
||||
}
|
||||
|
||||
func startSync() {
|
||||
MXLog.info("Starting sync")
|
||||
guard slidingSyncObserverToken == nil else {
|
||||
guard !isSyncing else {
|
||||
return
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -178,7 +192,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func createDirectRoom(with userID: String) async -> Result<String, ClientProxyError> {
|
||||
await Task.dispatch(on: clientQueue) {
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user