Skip to content

Commit

Permalink
Wrap subscription-related navigation links in LazyView (#3576)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samsymons authored Nov 16, 2024
1 parent 260b44b commit 700dcec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DuckDuckGo/SettingsSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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,
Expand All @@ -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 })
Expand Down

0 comments on commit 700dcec

Please sign in to comment.