Skip to content

Commit

Permalink
Clean up legacy VPN navigation (#3266)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1208118450361001/f
Tech Design URL:
CC:

Description:

This PR removes some cases where the VPN UI could possibly be blank:

1. The settings navigation logic was technically using an EmptyView if you try to navigate to the VPN with it
2. The VPN root view was checking the feature flag and only showing the UI if it's enabled, so if that flag was disabled for any reason the UI would be blank - since this flag is no longer necessary, I've removed the check
  • Loading branch information
samsymons authored Aug 22, 2024
1 parent bc43533 commit 196f641
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 98 deletions.
4 changes: 0 additions & 4 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@
EE01EB402AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE01EB3F2AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift */; };
EE01EB432AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE01EB422AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift */; };
EE0798C52B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0798C42B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift */; };
EE276BEA2A77F823009167B6 /* NetworkProtectionRootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */; };
EE3766DE2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3766DD2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift */; };
EE3B226B29DE0F110082298A /* MockInternalUserStoring.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */; };
EE3B226C29DE0FD30082298A /* MockInternalUserStoring.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */; };
Expand Down Expand Up @@ -2716,7 +2715,6 @@
EE01EB3F2AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNSettingsViewModel.swift; sourceTree = "<group>"; };
EE01EB422AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNLocationView.swift; sourceTree = "<group>"; };
EE0798C42B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNCountryLabelsModel.swift; sourceTree = "<group>"; };
EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionRootViewController.swift; sourceTree = "<group>"; };
EE3766DD2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionUNNotificationPresenter.swift; sourceTree = "<group>"; };
EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockInternalUserStoring.swift; sourceTree = "<group>"; };
EE3B98EA2A9634CC002F63A0 /* DuckDuckGoAlpha.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DuckDuckGoAlpha.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5194,7 +5192,6 @@
isa = PBXGroup;
children = (
EE0153EC2A6FF9E6002A8B26 /* NetworkProtectionRootView.swift */,
EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */,
);
name = Root;
sourceTree = "<group>";
Expand Down Expand Up @@ -7139,7 +7136,6 @@
6F691CCA2C4979EC002E9553 /* FavoritesTooltip.swift in Sources */,
D65625952C22D382006EF297 /* TabViewController.swift in Sources */,
8C4838B5221C8F7F008A6739 /* GestureToolbarButton.swift in Sources */,
EE276BEA2A77F823009167B6 /* NetworkProtectionRootViewController.swift in Sources */,
310ECFDD282A8BB0005029B3 /* EnableAutofillSettingsTableViewCell.swift in Sources */,
6F9FFE2A2C57ADB100A238BE /* EditableShortcutsView.swift in Sources */,
1E908BF329827C480008C8F3 /* AutoconsentManagement.swift in Sources */,
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {

func presentNetworkProtectionStatusSettingsModal() {
Task {
if case .success(let hasEntitlements) = await accountManager.hasEntitlement(forProductName: .networkProtection),
hasEntitlements {
let networkProtectionRoot = NetworkProtectionRootViewController()
presentSettings(with: networkProtectionRoot)
if case .success(let hasEntitlements) = await accountManager.hasEntitlement(forProductName: .networkProtection), hasEntitlements {
(window?.rootViewController as? MainViewController)?.segueToVPN()
} else {
(window?.rootViewController as? MainViewController)?.segueToPrivacyPro()
}
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ extension MainViewController {
}
}

func segueToVPN() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
launchSettings {
$0.triggerDeepLinkNavigation(to: .netP)
}
}

func segueToDebugSettings() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
Expand Down
13 changes: 8 additions & 5 deletions DuckDuckGo/NetworkProtectionRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import SwiftUI
import NetworkProtection
import Subscription
import Core

struct NetworkProtectionRootView: View {

let statusViewModel: NetworkProtectionStatusViewModel

init() {
Expand All @@ -33,11 +35,12 @@ struct NetworkProtectionRootView: View {
serverInfoObserver: AppDependencyProvider.shared.serverInfoObserver,
locationListRepository: locationListRepository)
}

var body: some View {
if AppDependencyProvider.shared.vpnFeatureVisibility.isPrivacyProLaunched() {
NetworkProtectionStatusView(
statusModel: statusViewModel
)
}
NetworkProtectionStatusView(statusModel: statusViewModel)
.navigationTitle(UserText.netPNavTitle)
.onFirstAppear {
Pixel.fire(pixel: .privacyProVPNSettings)
}
}
}
50 changes: 0 additions & 50 deletions DuckDuckGo/NetworkProtectionRootViewController.swift

This file was deleted.

5 changes: 2 additions & 3 deletions DuckDuckGo/SettingsLegacyViewProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class SettingsLegacyViewProvider: ObservableObject {
fireproofSites,
autoclearData,
keyboard,
netP,
feedback, debug
feedback,
debug
}

private func instantiate(_ identifier: String, fromStoryboard name: String) -> UIViewController {
Expand All @@ -81,7 +81,6 @@ class SettingsLegacyViewProvider: ObservableObject {
var autoclearData: UIViewController { instantiate("AutoClearSettingsViewController", fromStoryboard: "Settings") }
var keyboard: UIViewController { instantiate("Keyboard", fromStoryboard: "Settings") }
var feedback: UIViewController { instantiate("Feedback", fromStoryboard: "Feedback") }
var netP: UIViewController { NetworkProtectionRootViewController() }

@MainActor
var syncSettings: UIViewController {
Expand Down
16 changes: 2 additions & 14 deletions DuckDuckGo/SettingsRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ struct SettingsRootView: View {
DispatchQueue.main.async {
self.shouldDisplayDeepLinkPush = true
}
case.UIKitView:
DispatchQueue.main.async {
triggerLegacyLink(link)
}
}
})

Expand Down Expand Up @@ -129,19 +125,11 @@ struct SettingsRootView: View {
onDisappear: {})
case .duckPlayer:
SettingsDuckPlayerView().environmentObject(viewModel)
default:
EmptyView()
}
}

private func triggerLegacyLink(_ link: SettingsViewModel.SettingsDeepLinkSection) {
switch link {
case .netP:
viewModel.presentLegacyView(.netP)
default:
return
NetworkProtectionRootView()
}
}

}

struct InsetGroupedListStyleModifier: ViewModifier {
Expand Down
14 changes: 8 additions & 6 deletions DuckDuckGo/SettingsSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct SettingsSubscriptionView: View {
@EnvironmentObject var subscriptionNavigationCoordinator: SubscriptionNavigationCoordinator
@State var isShowingDBP = false
@State var isShowingITP = false
@State var isShowingVPN = false
@State var isShowingRestoreFlow = false
@State var isShowingGoogleView = false
@State var isShowingStripeView = false
Expand Down Expand Up @@ -155,12 +156,13 @@ struct SettingsSubscriptionView: View {
private var subscriptionDetailsView: some View {

if viewModel.state.subscription.entitlements.contains(.networkProtection) {
SettingsCellView(label: UserText.settingsPProVPNTitle,
image: Image("SettingsPrivacyProVPN"),
action: { viewModel.presentLegacyView(.netP) },
statusIndicator: StatusIndicatorView(status: viewModel.state.networkProtectionConnected ? .on : .off),
disclosureIndicator: true,
isButton: true)
NavigationLink(destination: NetworkProtectionRootView(), isActive: $isShowingVPN) {
SettingsCellView(
label: UserText.settingsPProVPNTitle,
image: Image("SettingsPrivacyProVPN"),
statusIndicator: StatusIndicatorView(status: viewModel.state.networkProtectionConnected ? .on : .off)
)
}
}

if viewModel.state.subscription.entitlements.contains(.dataBrokerProtection) {
Expand Down
13 changes: 1 addition & 12 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,6 @@ extension SettingsViewModel {

case .autoconsent:
pushViewController(legacyViewProvider.autoConsent)

case .netP:
firePixel(.privacyProVPNSettings)
pushViewController(legacyViewProvider.netP)
}
}

Expand Down Expand Up @@ -654,13 +650,7 @@ extension SettingsViewModel {
// Default to .sheet, specify .push where needed
var type: DeepLinkType {
switch self {
// Specify cases that require .push presentation
// Example:
// case .dbp:
// return .sheet
case .netP:
return .UIKitView
default:
case .netP, .dbp, .itr, .subscriptionFlow, .restoreFlow, .duckPlayer:
return .navigationLink
}
}
Expand All @@ -670,7 +660,6 @@ extension SettingsViewModel {
enum DeepLinkType {
case sheet
case navigationLink
case UIKitView
}

// Navigate to a section in settings
Expand Down

0 comments on commit 196f641

Please sign in to comment.