mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Perform client store optimizations when migrating versions.
This commit is contained in:
committed by
Stefan Ceriu
parent
57cd5dd794
commit
8a1d0fe8b1
@@ -428,6 +428,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
|
|
||||||
MXLog.info("Migrating user session from \(oldVersion)")
|
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) {
|
if oldVersion < Version(25, 6, 0) {
|
||||||
MXLog.info("Migrating to version 25.06.0, migrating timeline media settings to account data.")
|
MXLog.info("Migrating to version 25.06.0, migrating timeline media settings to account data.")
|
||||||
performSettingsToAccountDataMigration(userSession: userSession)
|
performSettingsToAccountDataMigration(userSession: userSession)
|
||||||
|
|||||||
@@ -4642,6 +4642,71 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
|||||||
return clearCachesReturnValue
|
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
|
//MARK: - fetchMediaPreviewConfiguration
|
||||||
|
|
||||||
var fetchMediaPreviewConfigurationUnderlyingCallsCount = 0
|
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> {
|
func fetchMediaPreviewConfiguration() async -> Result<MediaPreviewConfig?, ClientProxyError> {
|
||||||
do {
|
do {
|
||||||
let config = try await client.fetchMediaPreviewConfig()
|
let config = try await client.fetchMediaPreviewConfig()
|
||||||
|
|||||||
@@ -215,6 +215,8 @@ protocol ClientProxyProtocol: AnyObject {
|
|||||||
|
|
||||||
@discardableResult func clearCaches() async -> Result<Void, ClientProxyError>
|
@discardableResult func clearCaches() async -> Result<Void, ClientProxyError>
|
||||||
|
|
||||||
|
@discardableResult func optimizeStores() async -> Result<Void, ClientProxyError>
|
||||||
|
|
||||||
func fetchMediaPreviewConfiguration() async -> Result<MediaPreviewConfig?, ClientProxyError>
|
func fetchMediaPreviewConfiguration() async -> Result<MediaPreviewConfig?, ClientProxyError>
|
||||||
|
|
||||||
// MARK: - Ignored users
|
// MARK: - Ignored users
|
||||||
|
|||||||
Reference in New Issue
Block a user