Add a migration to expire sync sessions so that m.space.* state is up to date. (#4482)

This commit is contained in:
Doug
2025-09-09 15:35:32 +01:00
committed by GitHub
parent 2f2e6f6226
commit 19189bec06
6 changed files with 116 additions and 29 deletions
@@ -29,6 +29,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
/// Common background task to continue long-running tasks in the background.
private var backgroundTask: UIBackgroundTaskIdentifier?
private var userSessionMigrationsOldVersion: Version?
private var userSession: UserSessionProtocol? {
didSet {
userSessionObserver?.cancel()
@@ -37,7 +38,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
configureNotificationManager()
observeUserSessionChanges()
startSync()
performSettingsToAccountDataMigration(userSession: userSession)
Task { await performUserSessionMigrations(userSession) }
Task { await appHooks.configure(with: userSession) }
}
}
@@ -410,6 +411,27 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
Tracing.migrateLogFiles()
MXLog.info("Migrating to version 25.07.4, log files have been moved.")
}
// Store the old version to run additional migrations on the user session once it has been set up.
userSessionMigrationsOldVersion = oldVersion
}
private func performUserSessionMigrations(_ userSession: UserSessionProtocol) async {
guard let oldVersion = userSessionMigrationsOldVersion else { return }
MXLog.info("Migrating user session from \(oldVersion)")
if oldVersion < Version(25, 6, 0) {
MXLog.info("Migrating to version 25.06.0, migrating timeline media settings to account data.")
performSettingsToAccountDataMigration(userSession: userSession)
}
if oldVersion < Version(25, 9, 2) {
MXLog.info("Migrating to version 25.09.2, triggering sync to ensure m.space state is up to date.")
await userSession.clientProxy.expireSyncSessions()
}
userSessionMigrationsOldVersion = nil
}
// This could be removed once the adoption of 25.06.x is widespread.