Perform client store optimizations when migrating versions.
This commit is contained in:
committed by
Stefan Ceriu
parent
b08d4c9457
commit
2880ee9135
@@ -428,6 +428,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
MXLog.info("Migrating user session from \(oldVersion)")
|
||||
|
||||
MXLog.info("Performing client store optimizations.")
|
||||
await userSession.clientProxy.optimizeStores()
|
||||
MXLog.info("Finished optimizing client stores.")
|
||||
|
||||
if oldVersion < Version(25, 6, 0) {
|
||||
MXLog.info("Migrating to version 25.06.0, migrating timeline media settings to account data.")
|
||||
performSettingsToAccountDataMigration(userSession: userSession)
|
||||
|
||||
@@ -4642,6 +4642,71 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
return clearCachesReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - optimizeStores
|
||||
|
||||
var optimizeStoresUnderlyingCallsCount = 0
|
||||
var optimizeStoresCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return optimizeStoresUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = optimizeStoresUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
optimizeStoresUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
optimizeStoresUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var optimizeStoresCalled: Bool {
|
||||
return optimizeStoresCallsCount > 0
|
||||
}
|
||||
|
||||
var optimizeStoresUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
||||
var optimizeStoresReturnValue: Result<Void, ClientProxyError>! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return optimizeStoresUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Result<Void, ClientProxyError>? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = optimizeStoresUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
optimizeStoresUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
optimizeStoresUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var optimizeStoresClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||
|
||||
@discardableResult
|
||||
func optimizeStores() async -> Result<Void, ClientProxyError> {
|
||||
optimizeStoresCallsCount += 1
|
||||
if let optimizeStoresClosure = optimizeStoresClosure {
|
||||
return await optimizeStoresClosure()
|
||||
} else {
|
||||
return optimizeStoresReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - fetchMediaPreviewConfiguration
|
||||
|
||||
var fetchMediaPreviewConfigurationUnderlyingCallsCount = 0
|
||||
|
||||
@@ -807,6 +807,15 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func optimizeStores() async -> Result<Void, ClientProxyError> {
|
||||
do {
|
||||
return try await .success(client.optimizeStores())
|
||||
} catch {
|
||||
MXLog.error("Failed optimizing client stores with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func fetchMediaPreviewConfiguration() async -> Result<MediaPreviewConfig?, ClientProxyError> {
|
||||
do {
|
||||
let config = try await client.fetchMediaPreviewConfig()
|
||||
|
||||
@@ -215,6 +215,8 @@ protocol ClientProxyProtocol: AnyObject {
|
||||
|
||||
@discardableResult func clearCaches() async -> Result<Void, ClientProxyError>
|
||||
|
||||
@discardableResult func optimizeStores() async -> Result<Void, ClientProxyError>
|
||||
|
||||
func fetchMediaPreviewConfiguration() async -> Result<MediaPreviewConfig?, ClientProxyError>
|
||||
|
||||
// MARK: - Ignored users
|
||||
|
||||
Reference in New Issue
Block a user