diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 4d3d475c9..edf1c25df 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -9878,7 +9878,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 18.5; KEYCHAIN_ACCESS_GROUP_IDENTIFIER = "$(DEVELOPMENT_TEAM).$(BASE_BUNDLE_IDENTIFIER)"; MACOSX_DEPLOYMENT_TARGET = 14.5; - MARKETING_VERSION = 26.07.2; + MARKETING_VERSION = 26.07.3; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCTION_APP_NAME = Element; @@ -9958,7 +9958,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 18.5; KEYCHAIN_ACCESS_GROUP_IDENTIFIER = "$(DEVELOPMENT_TEAM).$(BASE_BUNDLE_IDENTIFIER)"; MACOSX_DEPLOYMENT_TARGET = 14.5; - MARKETING_VERSION = 26.07.2; + MARKETING_VERSION = 26.07.3; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 165c07ea7..052cefe79 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -504,6 +504,11 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg appSettings.hasSeenNewSoundBanner = false } + if oldVersion < Version(26, 07, 3) { + MXLog.info("Migrating to version 26.07.3, marking the app as previously signed in.") + appSettings.hasSignedInBefore = true + } + userSessionMigrationsOldVersion = nil } diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index fedea5b4b..f01de0f1a 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -293,6 +293,12 @@ final nonisolated class AppSettings: @unchecked Sendable { @UserPreference(defaultValue: AnalyticsConsentState.unknown) var analyticsConsentState: AnalyticsConsentState + /// Whether a user session has ever been set up on this device. Deliberately not cleared on + /// logout: it stops the Classic app migration prompt from reappearing when an Element X + /// user is signed out unexpectedly (invalidated token, corrupted storage, etc). + @UserPreference(defaultValue: false) + var hasSignedInBefore: Bool + @UserPreference(defaultValue: false) var hasRunNotificationPermissionsOnboarding: Bool diff --git a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift index 787cd4a41..7bcf797da 100644 --- a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift @@ -225,6 +225,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { presentNotificationPermissionsScreen() case (_, _, .finished): isNewLogin = false + appSettings.hasSignedInBefore = true actionsSubject.send(.dismiss) stateMachine.tryState(.initial) case (.finished, _, .initial): diff --git a/ElementX/Sources/Services/Authentication/AuthenticationService.swift b/ElementX/Sources/Services/Authentication/AuthenticationService.swift index 0226520db..0c2d653e2 100644 --- a/ElementX/Sources/Services/Authentication/AuthenticationService.swift +++ b/ElementX/Sources/Services/Authentication/AuthenticationService.swift @@ -46,7 +46,12 @@ class AuthenticationService: AuthenticationServiceProtocol { self.appHooks = appHooks do { - if let classicAppManager { + if appSettings.hasSignedInBefore { + // Element X has already been used on this device, so an account left behind by the + // Classic app is stale — don't offer to migrate it again after a logout. + MXLog.info("Already signed in to Element X before, skipping loadAccounts.") + classicAppAccount = nil + } else if let classicAppManager { classicAppAccount = try classicAppManager.loadAccounts().first } else { MXLog.info("Classic App not configured, skipping loadAccounts.") diff --git a/project.yml b/project.yml index d3707da4b..afca06f57 100644 --- a/project.yml +++ b/project.yml @@ -53,7 +53,7 @@ settings: ENABLE_BITCODE: false APP_NAME: ElementX KEYCHAIN_ACCESS_GROUP_IDENTIFIER: "$(DEVELOPMENT_TEAM).$(BASE_BUNDLE_IDENTIFIER)" - MARKETING_VERSION: 26.07.2 + MARKETING_VERSION: 26.07.3 CURRENT_PROJECT_VERSION: 1 SUPPORTS_MACCATALYST: false