From 700dcec529cae87789168d64431939b126a194cc Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Fri, 15 Nov 2024 18:44:40 -0800 Subject: [PATCH] Wrap subscription-related navigation links in `LazyView` (#3576) Task/Issue URL: https://app.asana.com/0/414235014887631/1208761754194252/f Tech Design URL: CC: Description: This PR fixes an issue where subscription views were being fully initialized from the settings screen, rather than initializing when being navigated to. This isn't a problem for most of the subscription views, but the VPN view was having all of its various subscribers etc. spun up and reacting to state when they shouldn't have been. --- DuckDuckGo/SettingsSubscriptionView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo/SettingsSubscriptionView.swift b/DuckDuckGo/SettingsSubscriptionView.swift index 6c22e97d9d..b2414c2855 100644 --- a/DuckDuckGo/SettingsSubscriptionView.swift +++ b/DuckDuckGo/SettingsSubscriptionView.swift @@ -157,7 +157,7 @@ struct SettingsSubscriptionView: View { private var subscriptionDetailsView: some View { if settingsViewModel.state.subscription.entitlements.contains(.networkProtection) { - NavigationLink(destination: NetworkProtectionRootView(), isActive: $isShowingVPN) { + NavigationLink(destination: LazyView(NetworkProtectionRootView()), isActive: $isShowingVPN) { SettingsCellView( label: UserText.settingsPProVPNTitle, image: Image("SettingsPrivacyProVPN"), @@ -167,7 +167,7 @@ struct SettingsSubscriptionView: View { } if settingsViewModel.state.subscription.entitlements.contains(.dataBrokerProtection) { - NavigationLink(destination: SubscriptionPIRView(), isActive: $isShowingDBP) { + NavigationLink(destination: LazyView(SubscriptionPIRView()), isActive: $isShowingDBP) { SettingsCellView( label: UserText.settingsPProDBPTitle, image: Image("SettingsPrivacyProPIR"), @@ -178,7 +178,7 @@ struct SettingsSubscriptionView: View { if settingsViewModel.state.subscription.entitlements.contains(.identityTheftRestoration) { NavigationLink( - destination: SubscriptionITPView(), + destination: LazyView(SubscriptionITPView()), isActive: $isShowingITP) { SettingsCellView( label: UserText.settingsPProITRTitle, @@ -188,7 +188,7 @@ struct SettingsSubscriptionView: View { } } - NavigationLink(destination: SubscriptionSettingsView(configuration: .subscribed, settingsViewModel: settingsViewModel) + NavigationLink(destination: LazyView(SubscriptionSettingsView(configuration: .subscribed, settingsViewModel: settingsViewModel)) .environmentObject(subscriptionNavigationCoordinator) ) { SettingsCustomCell(content: { manageSubscriptionView })