diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index cfb7fafa1..1b6039684 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -280,6 +280,10 @@ class ClientProxy: ClientProxyProtocol { Task { await syncService?.start() + + // If we are using OIDC we want to cache the account management URL in volatile memory on the SDK side. + // To avoid the cache being invalidated while the app is backgrounded, we cache at every sync start. + await cacheAccountURL() } } @@ -753,6 +757,11 @@ class ClientProxy: ClientProxyProtocol { // MARK: - Private + private func cacheAccountURL() async { + // Calling this function for the first time will cache the account URL in volatile memory for 24 hrs on the SDK. + _ = try? await client.accountUrl(action: nil) + } + private func updateVerificationState(_ verificationState: VerificationState) async { let verificationState: SessionVerificationState = switch verificationState { case .unknown: diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index a59c13655..ff690dc8b 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -112,8 +112,9 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func startSync() func stopSync() - func stopSync(completion: (() -> Void)?) // Hopefully this will become async once we get SE-0371. + func stopSync(completion: (() -> Void)?) // Hopefully this will become async once we get SE-0371. + func accountURL(action: AccountManagementAction) async -> URL? func directRoomForUserID(_ userID: String) async -> Result