summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2023-04-28 16:45:16 +0200
committerAndrej Mihajlov <and@mullvad.net>2023-04-28 16:45:16 +0200
commit2cc56a2f08f1697444f5ac6012092cca10ebc7ce (patch)
tree3d88dbd59f89ee1acad2037541c6c05ce580fad0
parent958b137e1cc9b2379d82832d5ad14150e5678625 (diff)
downloadmullvadvpn-2cc56a2f08f1697444f5ac6012092cca10ebc7ce.tar.xz
mullvadvpn-2cc56a2f08f1697444f5ac6012092cca10ebc7ce.zip
AppCoordinator: handle transition from and to expired state
-rw-r--r--ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift28
1 files changed, 18 insertions, 10 deletions
diff --git a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
index 190433b775..b4695072dd 100644
--- a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
@@ -634,11 +634,23 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
switch deviceState {
case let .loggedIn(accountData, _):
- updateOutOfTimeTimer()
+ updateOutOfTimeTimer(accountData: accountData)
updateView(deviceState: deviceState, showDeviceInfo: false)
- if !accountData.isExpired {
+
+ // Handle transition to and from expired state.
+ let accountWasExpired = previousDeviceState.accountData?.isExpired ?? false
+ switch (accountWasExpired, accountData.isExpired) {
+ case (true, false):
+ continueFlow(animated: true)
router.dismiss(.outOfTime, animated: true)
+
+ case (false, true):
+ router.present(.outOfTime, animated: true)
+
+ default:
+ break
}
+
case .revoked:
cancelOutOfTimeTimer()
router.present(.revoked, animated: true)
@@ -663,13 +675,13 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
// MARK: - Out of time
- private func updateOutOfTimeTimer() {
+ private func updateOutOfTimeTimer(accountData: StoredAccountData) {
cancelOutOfTimeTimer()
- guard let expiry = tunnelManager.deviceState.accountData?.expiry else { return }
+ guard !accountData.isExpired else { return }
- let timer = Timer(fire: expiry, interval: 0, repeats: false, block: { [weak self] _ in
- self?.outOfTimeTimerDidFire()
+ let timer = Timer(fire: accountData.expiry, interval: 0, repeats: false, block: { [weak self] _ in
+ self?.router.present(.outOfTime, animated: true)
})
RunLoop.main.add(timer, forMode: .common)
@@ -677,10 +689,6 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
outOfTimeTimer = timer
}
- private func outOfTimeTimerDidFire() {
- router.present(.outOfTime, animated: true)
- }
-
private func cancelOutOfTimeTimer() {
outOfTimeTimer?.invalidate()
outOfTimeTimer = nil