diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index addf461e2..82a37cc7e 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -81,6 +81,7 @@ final class AppSettings { case focusEventOnNotificationTap case linkNewDeviceEnabled case automaticBackPaginationEnabled + case clientPausingAndResumingEnabled // Doug's tweaks 🔧 case roomListActivityVisibility @@ -448,6 +449,9 @@ final class AppSettings { @UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store)) var automaticBackPaginationEnabled + @UserPreference(key: UserDefaultsKeys.clientPausingAndResumingEnabled, defaultValue: appBuildType != .release, storageType: .volatile) + var clientPausingAndResumingEnabled + @UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType != .release, storageType: .userDefaults(store)) var developerOptionsEnabled } diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 1ff29d450..dbcb037ce 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -403,6 +403,14 @@ class ClientProxy: ClientProxyProtocol { MXLog.info("Starting sync") Task { + if appSettings.clientPausingAndResumingEnabled { + do { + try await client.resume() + } catch { + MXLog.error("Failed resuming client with error: \(error)") + } + } + await syncService.start() // 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() + + if appSettings.clientPausingAndResumingEnabled { + do { + try await client.pause() + } catch { + MXLog.error("Failed pausing client with error: \(error)") + } + } + MXLog.info("Sync stopped") } }