Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Fixed NetShield selection in setting window
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslavas committed Jan 11, 2021
1 parent 558d50d commit c8d66ed
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions ProtonVPN/GeneralViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,17 @@ class GeneralViewModel {
break
}

let userTier = (try? vpnGateway.userTier()) ?? 0
guard netShieldPropertyProvider.isUserEligibleForNetShield else {
let upgradeAlert = NetShieldRequiresUpgradeAlert(continueHandler: {
SafariService.openLink(url: CoreAppConstants.ProtonVpnLinks.accountDashboard)
})

self.alertService.push(alert: upgradeAlert)
viewController?.reloadView()
return
}

if !isConnected && !netShieldType.isUserTierTooLow(userTier) {
guard isConnected else {
netShieldPropertyProvider.netShieldType = netShieldType
viewController?.reloadView()
return
Expand All @@ -124,21 +132,6 @@ class GeneralViewModel {
self.viewController?.reloadView()
})

switch netShieldType {
case .off, .level1:
self.alertService.push(alert: reconnectAlert)
case .level2:
guard netShieldType.isUserTierTooLow(userTier) else {
self.alertService.push(alert: reconnectAlert)
return
}

let upgradeAlert = NetShieldRequiresUpgradeAlert(continueHandler: {
SafariService.openLink(url: CoreAppConstants.ProtonVpnLinks.accountDashboard)
})

self.alertService.push(alert: upgradeAlert)
viewController?.reloadView()
}
self.alertService.push(alert: reconnectAlert)
}
}

0 comments on commit c8d66ed

Please sign in to comment.