diff --git a/ElementX/Sources/Application/Windowing/WindowManager.swift b/ElementX/Sources/Application/Windowing/WindowManager.swift index 84b72d342..1bfdf3b46 100644 --- a/ElementX/Sources/Application/Windowing/WindowManager.swift +++ b/ElementX/Sources/Application/Windowing/WindowManager.swift @@ -63,10 +63,10 @@ class WindowManager { /// Shows the main and overlay window combo, hiding the alternate window. func switchToMain() { + mainWindow.isHidden = false + overlayWindow.isHidden = false + switchTask = Task { - mainWindow.isHidden = false - overlayWindow.isHidden = false - // Delay hiding to make sure the main windows are visible. try await Task.sleep(for: windowHideDelay) @@ -76,14 +76,17 @@ class WindowManager { /// Shows the alternate window, hiding the main and overlay combo. func switchToAlternate() { + alternateWindow.isHidden = false + + // We don't know what route the app will use when returning back + // to the main window, so end any editing operation now to avoid + // e.g. the keyboard being displayed on top of a call sheet. + mainWindow.endEditing(true) + + // alternateWindow.isHidden = false cannot got inside the Task otherwise the timing + // is poor when you lock the phone - you briefly see the main window for a few + // frames after you've unlocked the phone and then the placeholder animates in. switchTask = Task { - alternateWindow.isHidden = false - - // We don't know what route the app will use when returning back - // to the main window, so end any editing operation now to avoid - // e.g. the keyboard being displayed on top of a call sheet. - mainWindow.endEditing(true) - // Delay hiding to make sure the alternate window is visible. try await Task.sleep(for: windowHideDelay) diff --git a/ElementX/Sources/FlowCoordinators/AppLockFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/AppLockFlowCoordinator.swift index 1a6c60e34..d75dd7c05 100644 --- a/ElementX/Sources/FlowCoordinators/AppLockFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/AppLockFlowCoordinator.swift @@ -108,7 +108,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol { if appLockService.biometricUnlockEnabled, appLockService.biometricUnlockTrusted { showPlaceholder() // For the unlock background. - if await appLockService.unlockWithBiometrics() { + if await appLockService.unlockWithBiometrics(), UIApplication.shared.applicationState == .active { actionsSubject.send(.unlockApp) return } @@ -132,6 +132,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol { guard let self else { return } switch action { case .appUnlocked: + guard UIApplication.shared.applicationState == .active else { return } actionsSubject.send(.unlockApp) case .forceLogout: actionsSubject.send(.forceLogout)