Skip to content

Commit

Permalink
Refactor FXIOS-7301 - Remove 1 closure_body_length violation from Bro…
Browse files Browse the repository at this point in the history
…wserViewController.swift (#21334)

* Extract microsurvey actions to a new function

* Use the new function

* Change access modifier
  • Loading branch information
ionixjunior authored Aug 14, 2024
1 parent ecc6357 commit 29a3c27
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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() {
Expand Down

0 comments on commit 29a3c27

Please sign in to comment.