mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Add an extra call to obscure the app on willEnterForeground. (#2202)
It shouldn't be necessary given the double call by the time the app is backgrounded, but we're still seeing occasional room list flashes.
This commit is contained in:
parent
e5bd194d06
commit
7da881ae3e
@ -44,6 +44,8 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
|||||||
case appObscured
|
case appObscured
|
||||||
/// The app is in the background.
|
/// The app is in the background.
|
||||||
case backgrounded
|
case backgrounded
|
||||||
|
/// The app is returning to the foreground.
|
||||||
|
case launching
|
||||||
/// The app is presenting biometric unlock to the user.
|
/// The app is presenting biometric unlock to the user.
|
||||||
case attemptingBiometricUnlock
|
case attemptingBiometricUnlock
|
||||||
/// Biometric unlock has completed but the system UI is still the active input.
|
/// Biometric unlock has completed but the system UI is still the active input.
|
||||||
@ -63,6 +65,8 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
|||||||
case willResignActive
|
case willResignActive
|
||||||
/// The app is now backgrounded and not visible to the user.
|
/// The app is now backgrounded and not visible to the user.
|
||||||
case didEnterBackground
|
case didEnterBackground
|
||||||
|
/// The app is in the background and has just been launched by the user.
|
||||||
|
case willEnterForeground
|
||||||
/// The app is in the foreground and has been given focus.
|
/// The app is in the foreground and has been given focus.
|
||||||
case didBecomeActive
|
case didBecomeActive
|
||||||
/// Biometric unlock has completed with the following result.
|
/// Biometric unlock has completed with the following result.
|
||||||
@ -116,6 +120,12 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
|
notificationCenter.publisher(for: UIApplication.willEnterForegroundNotification)
|
||||||
|
.sink { [weak self] _ in
|
||||||
|
self?.stateMachine.tryEvent(.willEnterForeground)
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
|
|
||||||
notificationCenter.publisher(for: UIApplication.didBecomeActiveNotification)
|
notificationCenter.publisher(for: UIApplication.didBecomeActiveNotification)
|
||||||
.sink { [weak self] _ in
|
.sink { [weak self] _ in
|
||||||
self?.stateMachine.tryEvent(.didBecomeActive)
|
self?.stateMachine.tryEvent(.didBecomeActive)
|
||||||
@ -149,7 +159,9 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
|||||||
return .unlocked
|
return .unlocked
|
||||||
case (_, .didEnterBackground):
|
case (_, .didEnterBackground):
|
||||||
return .backgrounded
|
return .backgrounded
|
||||||
case (.backgrounded, .didBecomeActive):
|
case (_, .willEnterForeground):
|
||||||
|
return .launching
|
||||||
|
case (.launching, .didBecomeActive):
|
||||||
guard appLockService.computeNeedsUnlock(didBecomeActiveAt: .now) else { return .unlocked }
|
guard appLockService.computeNeedsUnlock(didBecomeActiveAt: .now) else { return .unlocked }
|
||||||
return isBiometricUnlockAvailable ? .attemptingBiometricUnlock : .attemptingPINUnlock
|
return isBiometricUnlockAvailable ? .attemptingBiometricUnlock : .attemptingPINUnlock
|
||||||
case (.attemptingBiometricUnlock, .didFinishBiometricUnlock(let result)):
|
case (.attemptingBiometricUnlock, .didFinishBiometricUnlock(let result)):
|
||||||
@ -188,8 +200,10 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
|||||||
case (_, .backgrounded):
|
case (_, .backgrounded):
|
||||||
appLockService.applicationDidEnterBackground()
|
appLockService.applicationDidEnterBackground()
|
||||||
showPlaceholder() // Double call but just to be safe. Useful at app launch.
|
showPlaceholder() // Double call but just to be safe. Useful at app launch.
|
||||||
|
case (_, .launching):
|
||||||
|
showPlaceholder() // Triple call but necessary after being suspended.
|
||||||
case (_, .attemptingBiometricUnlock):
|
case (_, .attemptingBiometricUnlock):
|
||||||
showPlaceholder() // For the unlock background. Triple call but just to be safe.
|
showPlaceholder() // For the unlock background. Quadruple call but just to be safe.
|
||||||
Task { await self.attemptBiometricUnlock() }
|
Task { await self.attemptBiometricUnlock() }
|
||||||
case (.attemptingBiometricUnlock, .dismissingBiometricUnlock):
|
case (.attemptingBiometricUnlock, .dismissingBiometricUnlock):
|
||||||
break // Transitional state, no need to do anything.
|
break // Transitional state, no need to do anything.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user