From 515891701e205139f1ede6c930155779feb18a45 Mon Sep 17 00:00:00 2001 From: Daniel Bernal Date: Tue, 26 Mar 2024 13:01:27 +0100 Subject: [PATCH] Subscriptions: 24. Properly dismiss view on selecting feature (#2640) --- .../Subscription/ViewModel/SubscriptionEmailViewModel.swift | 5 +++++ DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/DuckDuckGo/Subscription/ViewModel/SubscriptionEmailViewModel.swift b/DuckDuckGo/Subscription/ViewModel/SubscriptionEmailViewModel.swift index 638c1d313d..85156254be 100644 --- a/DuckDuckGo/Subscription/ViewModel/SubscriptionEmailViewModel.swift +++ b/DuckDuckGo/Subscription/ViewModel/SubscriptionEmailViewModel.swift @@ -152,6 +152,11 @@ final class SubscriptionEmailViewModel: ObservableObject { self.selectedFeature = .dbp } self.state.shouldDismissStack = true + + // Reset shouldDismissStack after dismissal to ensure it can be triggered again + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + self.state.shouldDismissStack = false + } } } diff --git a/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift b/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift index 99fe2c826a..6371cad8e6 100644 --- a/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift +++ b/DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift @@ -86,6 +86,10 @@ struct SubscriptionEmailView: View { shouldDisplayNavigationError = value } + .onChange(of: viewModel.state.shouldDismissStack) { _ in + onDismissStack?() + } + // Observe changes to shouldDismissView .onChange(of: viewModel.state.shouldDismissView) { shouldDismiss in if shouldDismiss {