mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix a regression where the forced logout indicator was presented on the hidden overlay window. (#2063)
This commit is contained in:
@@ -49,13 +49,6 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
// Set the initial background state.
|
||||
showPlaceholder()
|
||||
|
||||
appLockService.disabledPublisher
|
||||
.sink {
|
||||
// When the service is disabled via a force logout, we need to remove the activity indicator.
|
||||
ServiceLocator.shared.userIndicatorController.retractAllIndicators()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
notificationCenter.publisher(for: UIApplication.didEnterBackgroundNotification)
|
||||
.sink { [weak self] _ in
|
||||
self?.applicationDidEnterBackground()
|
||||
@@ -131,7 +124,6 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
|
||||
case .appUnlocked:
|
||||
actionsSubject.send(.unlockApp)
|
||||
case .forceLogout:
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(type: .modal, title: L10n.commonSigningOut, persistent: true))
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ struct AppLockScreenViewState: BindableState {
|
||||
|
||||
/// The number of times the user attempted to enter their PIN.
|
||||
var numberOfPINAttempts = 0
|
||||
/// An overlay indicator shown when the user is being logged out.
|
||||
var forcedLogoutIndicator: UserIndicator?
|
||||
|
||||
var bindings: AppLockScreenViewStateBindings
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class AppLockScreenViewModel: AppLockScreenViewModelType, AppLockScreenViewModel
|
||||
state.bindings.alertInfo = .init(id: .confirmResetPIN,
|
||||
title: L10n.screenAppLockSignoutAlertTitle,
|
||||
message: L10n.screenAppLockSignoutAlertMessage,
|
||||
primaryButton: .init(title: L10n.actionOk) { self.actionsSubject.send(.forceLogout) },
|
||||
primaryButton: .init(title: L10n.actionOk) { self.forceLogout() },
|
||||
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
|
||||
}
|
||||
|
||||
@@ -90,7 +90,12 @@ class AppLockScreenViewModel: AppLockScreenViewModelType, AppLockScreenViewModel
|
||||
state.bindings.alertInfo = .init(id: .forcedLogout,
|
||||
title: L10n.screenAppLockSignoutAlertTitle,
|
||||
message: L10n.screenAppLockSignoutAlertMessage,
|
||||
primaryButton: .init(title: L10n.actionOk) { self.actionsSubject.send(.forceLogout) })
|
||||
primaryButton: .init(title: L10n.actionOk) { self.forceLogout() })
|
||||
}
|
||||
}
|
||||
|
||||
private func forceLogout() {
|
||||
state.forcedLogoutIndicator = UserIndicator(type: .modal, title: L10n.commonSigningOut, persistent: true)
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ struct AppLockScreen: View {
|
||||
}
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.disabled(context.viewState.forcedLogoutIndicator != nil)
|
||||
.overlay {
|
||||
context.viewState.forcedLogoutIndicator.map(UserIndicatorModalView.init)
|
||||
.animation(.elementDefault, value: context.viewState.forcedLogoutIndicator)
|
||||
}
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,6 @@ class AppLockService: AppLockServiceProtocol {
|
||||
|
||||
var numberOfPINAttempts: AnyPublisher<Int, Never> { appSettings.$appLockNumberOfPINAttempts }
|
||||
|
||||
private var disabledSubject: PassthroughSubject<Void, Never> = .init()
|
||||
var disabledPublisher: AnyPublisher<Void, Never> { disabledSubject.eraseToAnyPublisher() }
|
||||
|
||||
init(keychainController: KeychainControllerProtocol, appSettings: AppSettings, context: LAContext = .init()) {
|
||||
self.keychainController = keychainController
|
||||
self.appSettings = appSettings
|
||||
@@ -108,7 +105,6 @@ class AppLockService: AppLockServiceProtocol {
|
||||
keychainController.removePINCode()
|
||||
keychainController.removePINCodeBiometricState()
|
||||
appSettings.appLockNumberOfPINAttempts = 0
|
||||
disabledSubject.send()
|
||||
}
|
||||
|
||||
func applicationDidEnterBackground() {
|
||||
|
||||
@@ -45,9 +45,6 @@ protocol AppLockServiceProtocol: AnyObject {
|
||||
/// to re-enter their PIN code to re-enable the feature (i.e. to accept a new face or fingerprint).
|
||||
var biometricUnlockTrusted: Bool { get }
|
||||
|
||||
/// A publisher that advertises when the service has been disabled.
|
||||
var disabledPublisher: AnyPublisher<Void, Never> { get }
|
||||
|
||||
/// Sets the user's PIN code used to unlock the app.
|
||||
func setupPINCode(_ pinCode: String) -> Result<Void, AppLockServiceError>
|
||||
/// Validates the supplied PIN code is long enough, only contains digits and isn't a weak choice.
|
||||
|
||||
Reference in New Issue
Block a user