From 015f7bf81f54697e49aad6a8c58bd04ab2375ef8 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Tue, 7 Nov 2023 15:43:49 +0100 Subject: [PATCH] Fix expired account UI showing blocked state instead of out of time view --- .../Coordinators/ApplicationCoordinator.swift | 14 +++++++++++--- .../TunnelStatusNotificationProvider.swift | 4 +--- ios/MullvadVPN/TunnelManager/TunnelState.swift | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift b/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift index f5fce3f250f1..af0a8f8e47a9 100644 --- a/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift @@ -781,9 +781,17 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo private func addTunnelObserver() { let tunnelObserver = - TunnelBlockObserver(didUpdateDeviceState: { [weak self] _, deviceState, previousDeviceState in - self?.deviceStateDidChange(deviceState, previousDeviceState: previousDeviceState) - }) + TunnelBlockObserver( + didUpdateTunnelStatus: { [weak self] _, tunnelStatus in + if case let .error(observedState) = tunnelStatus.observedState, + observedState.reason == .accountExpired { + self?.router.present(.outOfTime) + } + }, + didUpdateDeviceState: { [weak self] _, deviceState, previousDeviceState in + self?.deviceStateDidChange(deviceState, previousDeviceState: previousDeviceState) + } + ) tunnelManager.addObserver(tunnelObserver) diff --git a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift index 300de34ad734..f87b35c45bbc 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift @@ -57,7 +57,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific private func handleTunnelStatus(_ tunnelStatus: TunnelStatus) { let invalidateForTunnelError: Bool - if case let .error(blockStateReason) = tunnelStatus.state { + if case let .error(blockStateReason) = tunnelStatus.state, blockStateReason != .accountExpired { invalidateForTunnelError = updateLastTunnelError(blockStateReason) } else { invalidateForTunnelError = updateLastTunnelError(nil) @@ -231,8 +231,6 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific errorString = "No servers match your settings, try changing server or other settings." case .invalidAccount: errorString = "You are logged in with an invalid account number. Please log out and try another one." - case .accountExpired: - errorString = "Account is out of time." case .deviceRevoked, .deviceLoggedOut: errorString = "Unable to authenticate account. Please log out and log back in." default: diff --git a/ios/MullvadVPN/TunnelManager/TunnelState.swift b/ios/MullvadVPN/TunnelManager/TunnelState.swift index 877046cac8c7..fd013ece4c07 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelState.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelState.swift @@ -99,7 +99,7 @@ enum TunnelState: Equatable, CustomStringConvertible { var isSecured: Bool { switch self { - case .reconnecting, .connecting, .connected, .waitingForConnectivity(.noConnection): + case .reconnecting, .connecting, .connected, .waitingForConnectivity(.noConnection), .error(.accountExpired): return true case .pendingReconnect, .disconnecting, .disconnected, .waitingForConnectivity(.noNetwork), .error: return false