mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Hook up client pausing and resuming next to sync starting and stopping for nightly and debug builds.
This will hopefully close all file descriptors and prevent the system from killing the app in the background. Reported in https://github.com/matrix-org/matrix-rust-sdk/issues/6366 and implemented in https://github.com/matrix-org/matrix-rust-sdk/pull/6495
This commit is contained in:
@@ -81,6 +81,7 @@ final class AppSettings {
|
|||||||
case focusEventOnNotificationTap
|
case focusEventOnNotificationTap
|
||||||
case linkNewDeviceEnabled
|
case linkNewDeviceEnabled
|
||||||
case automaticBackPaginationEnabled
|
case automaticBackPaginationEnabled
|
||||||
|
case clientPausingAndResumingEnabled
|
||||||
|
|
||||||
// Doug's tweaks 🔧
|
// Doug's tweaks 🔧
|
||||||
case roomListActivityVisibility
|
case roomListActivityVisibility
|
||||||
@@ -448,6 +449,9 @@ final class AppSettings {
|
|||||||
@UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||||
var automaticBackPaginationEnabled
|
var automaticBackPaginationEnabled
|
||||||
|
|
||||||
|
@UserPreference(key: UserDefaultsKeys.clientPausingAndResumingEnabled, defaultValue: appBuildType != .release, storageType: .volatile)
|
||||||
|
var clientPausingAndResumingEnabled
|
||||||
|
|
||||||
@UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType != .release, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType != .release, storageType: .userDefaults(store))
|
||||||
var developerOptionsEnabled
|
var developerOptionsEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,6 +403,14 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
MXLog.info("Starting sync")
|
MXLog.info("Starting sync")
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
|
if appSettings.clientPausingAndResumingEnabled {
|
||||||
|
do {
|
||||||
|
try await client.resume()
|
||||||
|
} catch {
|
||||||
|
MXLog.error("Failed resuming client with error: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await syncService.start()
|
await syncService.start()
|
||||||
|
|
||||||
// If we are using OAuth we want to cache the account management URL in volatile memory on the SDK side.
|
// If we are using OAuth we want to cache the account management URL in volatile memory on the SDK side.
|
||||||
@@ -454,6 +462,15 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await syncService.stop()
|
await syncService.stop()
|
||||||
|
|
||||||
|
if appSettings.clientPausingAndResumingEnabled {
|
||||||
|
do {
|
||||||
|
try await client.pause()
|
||||||
|
} catch {
|
||||||
|
MXLog.error("Failed pausing client with error: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MXLog.info("Sync stopped")
|
MXLog.info("Sync stopped")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user