Skip to content

Commit

Permalink
Fix expired account UI showing blocked state instead of out of time view
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson authored and buggmagnet committed Nov 9, 2023
1 parent bb568e8 commit 015f7bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
14 changes: 11 additions & 3 deletions ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/TunnelState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 015f7bf

Please sign in to comment.