From b1afd463a41256ede8990594b5d852c5bb058bc6 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Tue, 4 Jun 2024 15:03:21 -0700 Subject: [PATCH] Load child Privacy Pro views lazily (#2917) Task/Issue URL: https://app.asana.com/0/547792610048271/1207482157703809/f Tech Design URL: CC: Description: This PR updates Privacy Pro child views to load lazily. Without this, we were loading all of them as soon as the Privacy Pro flow was opened, and attempting to check auth state etc. --- Core/PixelEvent.swift | 4 ++-- DuckDuckGo/EventMapping+NetworkProtectionError.swift | 2 +- DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift | 6 +++--- DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift | 6 +++--- .../NetworkProtectionPacketTunnelProvider.swift | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index d57161e78f..f2f9bd6041 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -372,7 +372,7 @@ extension Pixel { case networkProtectionDisconnected - case networkProtectionNoAuthTokenFoundError + case networkProtectionNoAccessTokenFoundError case networkProtectionMemoryWarning case networkProtectionMemoryCritical @@ -1058,7 +1058,7 @@ extension Pixel.Event { case .networkProtectionActivationRequestFailed: return "m_netp_network_extension_error_activation_request_failed" case .networkProtectionFailedToStartTunnel: return "m_netp_failed_to_start_tunnel" case .networkProtectionDisconnected: return "m_netp_vpn_disconnect" - case .networkProtectionNoAuthTokenFoundError: return "m_netp_no_auth_token_found_error" + case .networkProtectionNoAccessTokenFoundError: return "m_netp_no_access_token_found_error" case .networkProtectionMemoryWarning: return "m_netp_vpn_memory_warning" case .networkProtectionMemoryCritical: return "m_netp_vpn_memory_critical" case .networkProtectionUnhandledError: return "m_netp_unhandled_error" diff --git a/DuckDuckGo/EventMapping+NetworkProtectionError.swift b/DuckDuckGo/EventMapping+NetworkProtectionError.swift index 8e8b428b47..fda64f9842 100644 --- a/DuckDuckGo/EventMapping+NetworkProtectionError.swift +++ b/DuckDuckGo/EventMapping+NetworkProtectionError.swift @@ -69,7 +69,7 @@ extension EventMapping where Event == NetworkProtectionError { pixelEvent = .networkProtectionKeychainDeleteError params[PixelParameters.keychainErrorCode] = String(status) case .noAuthTokenFound: - pixelEvent = .networkProtectionNoAuthTokenFoundError + pixelEvent = .networkProtectionNoAccessTokenFoundError case .vpnAccessRevoked: return case .noServerRegistrationInfo, diff --git a/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift b/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift index 93f3cefb3a..1e10c205f2 100644 --- a/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift +++ b/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift @@ -43,13 +43,13 @@ struct SubscriptionEmailView: View { var body: some View { // Hidden Navigation Links for Onboarding sections - NavigationLink(destination: NetworkProtectionRootView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(NetworkProtectionRootView().navigationViewStyle(.stack)), isActive: $isShowingNetP, label: { EmptyView() }) - NavigationLink(destination: SubscriptionITPView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(SubscriptionITPView().navigationViewStyle(.stack)), isActive: $isShowingITR, label: { EmptyView() }) - NavigationLink(destination: SubscriptionPIRView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(SubscriptionPIRView().navigationViewStyle(.stack)), isActive: $isShowingDBP, label: { EmptyView() }) diff --git a/DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift b/DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift index 3134549d1a..e891ce3348 100644 --- a/DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift +++ b/DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift @@ -55,13 +55,13 @@ struct SubscriptionFlowView: View { var body: some View { // Hidden Navigation Links for Onboarding sections - NavigationLink(destination: NetworkProtectionRootView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(NetworkProtectionRootView().navigationViewStyle(.stack)), isActive: $isShowingNetP, label: { EmptyView() }) - NavigationLink(destination: SubscriptionITPView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(SubscriptionITPView().navigationViewStyle(.stack)), isActive: $isShowingITR, label: { EmptyView() }) - NavigationLink(destination: SubscriptionPIRView().navigationViewStyle(.stack), + NavigationLink(destination: LazyView(SubscriptionPIRView().navigationViewStyle(.stack)), isActive: $isShowingDBP, label: { EmptyView() }) diff --git a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift index 856c68e713..1a4d15e355 100644 --- a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift +++ b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift @@ -213,7 +213,7 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider { pixelEvent = .networkProtectionWireguardErrorCannotStartWireguardBackend params[PixelParameters.wireguardErrorCode] = String(code) case .noAuthTokenFound: - pixelEvent = .networkProtectionNoAuthTokenFoundError + pixelEvent = .networkProtectionNoAccessTokenFoundError case .vpnAccessRevoked: return case .unhandledError(function: let function, line: let line, error: let error):