Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show account revoked banner when on account revoked screen #5531

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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."
Expand Down
Loading