diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift index fa05bd0eaa97..ec35492c5e2e 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift @@ -642,20 +642,7 @@ class BrowserViewController: UIViewController, executeToolbarActions() - // Microsurveys - if !state.microsurveyState.showPrompt { - guard microsurvey != nil else { return } - removeMicrosurveyPrompt() - } else if state.microsurveyState.showSurvey { - guard let model = state.microsurveyState.model else { - logger.log("Microsurvey model should not be nil", level: .warning, category: .redux) - return - } - navigationHandler?.showMicrosurvey(model: model) - } else if state.microsurveyState.showPrompt { - guard microsurvey == nil else { return } - createMicrosurveyPrompt(with: state.microsurveyState) - } + handleMicrosurvey(state: state) } } @@ -675,6 +662,22 @@ class BrowserViewController: UIViewController, show(toast: toast) } + private func handleMicrosurvey(state: BrowserViewControllerState) { + if !state.microsurveyState.showPrompt { + guard microsurvey != nil else { return } + removeMicrosurveyPrompt() + } else if state.microsurveyState.showSurvey { + guard let model = state.microsurveyState.model else { + logger.log("Microsurvey model should not be nil", level: .warning, category: .redux) + return + } + navigationHandler?.showMicrosurvey(model: model) + } else if state.microsurveyState.showPrompt { + guard microsurvey == nil else { return } + createMicrosurveyPrompt(with: state.microsurveyState) + } + } + // MARK: - Lifecycle override func viewDidLoad() {