summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2023-12-05 13:16:57 +0100
committerBug Magnet <marco.nikic@mullvad.net>2023-12-05 13:16:57 +0100
commitf2594c141c96aee97d54e69d18a3984c8f60e7b8 (patch)
treedc965f181f0c32efa88b8ec006961db549c000fa
parentf61abd92b646c5e379d13617d7012bab5017878b (diff)
parent6578f248c800c0ba6a5c1bf9d668a29a9d3b6d5e (diff)
downloadmullvadvpn-f2594c141c96aee97d54e69d18a3984c8f60e7b8.tar.xz
mullvadvpn-f2594c141c96aee97d54e69d18a3984c8f60e7b8.zip
Merge branch 'when-the-revoked-view-is-shown-and-the-app-fails-to-ios-396'
-rw-r--r--ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift27
1 files changed, 18 insertions, 9 deletions
diff --git a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
index f87b35c45b..84b5e9828d 100644
--- a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
+++ b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
@@ -56,13 +56,7 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific
// MARK: - Private
private func handleTunnelStatus(_ tunnelStatus: TunnelStatus) {
- let invalidateForTunnelError: Bool
- if case let .error(blockStateReason) = tunnelStatus.state, blockStateReason != .accountExpired {
- invalidateForTunnelError = updateLastTunnelError(blockStateReason)
- } else {
- invalidateForTunnelError = updateLastTunnelError(nil)
- }
-
+ let invalidateForTunnelError = updateLastTunnelError(tunnelStatus.state)
let invalidateForManagerError = updateTunnelManagerError(tunnelStatus.state)
let invalidateForConnectivity = updateConnectivity(tunnelStatus.state)
let invalidateForNetwork = updateNetwork(tunnelStatus.state)
@@ -72,7 +66,9 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific
}
}
- private func updateLastTunnelError(_ lastTunnelError: BlockedStateReason?) -> Bool {
+ private func updateLastTunnelError(_ tunnelState: TunnelState) -> Bool {
+ let lastTunnelError = tunnelError(from: tunnelState)
+
if packetTunnelError != lastTunnelError {
packetTunnelError = lastTunnelError
@@ -121,6 +117,19 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific
return false
}
+ // Extracts the blocked state reason from tunnel state with a few exceptions.
+ // We already have dedicated screens for .accountExpired and .deviceRevoked,
+ // so no need to show banners as well.
+ private func tunnelError(from tunnelState: TunnelState) -> BlockedStateReason? {
+ let errorsToIgnore: [BlockedStateReason] = [.accountExpired, .deviceRevoked]
+
+ if case let .error(blockedStateReason) = tunnelState, !errorsToIgnore.contains(blockedStateReason) {
+ return blockedStateReason
+ }
+
+ return nil
+ }
+
private func notificationDescription(for packetTunnelError: BlockedStateReason) -> InAppNotificationDescriptor {
InAppNotificationDescriptor(
identifier: identifier,
@@ -231,7 +240,7 @@ 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 .deviceRevoked, .deviceLoggedOut:
+ case .deviceLoggedOut:
errorString = "Unable to authenticate account. Please log out and log back in."
default:
errorString = "Unable to start tunnel connection. Please send a problem report."