Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix FXIOS-10437 [Menu] Attempt fix for menu coordinator bug (backport #23458) #23479

Open
wants to merge 1 commit into
base: release/v133
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,16 @@ class BrowserCoordinator: BaseCoordinator,
}

private func makeMenuNavViewController() -> DismissableNavigationViewController? {
guard !childCoordinators.contains(where: { $0 is MainMenuCoordinator }) else {
if let mainMenuCoordinator = childCoordinators.first(where: { $0 is MainMenuCoordinator }) as? MainMenuCoordinator {
logger.log(
"MainMenuCoordinator already exists when it technically shouldn't",
"MainMenuCoordinator already exists when it shouldn't. Removing and recreating it to access menu",
level: .fatal,
category: .mainMenu
category: .mainMenu,
extra: ["existing mainMenuCoordinator UUID": "\(mainMenuCoordinator.windowUUID)",
"BrowserCoordinator windowUUID": "\(windowUUID)"]
)
return nil

mainMenuCoordinator.dismissMenuModal(animated: false)
}

let navigationController = DismissableNavigationViewController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable {
weak var parentCoordinator: ParentCoordinatorDelegate?
weak var navigationHandler: MainMenuCoordinatorDelegate?

private let windowUUID: WindowUUID
let windowUUID: WindowUUID
private let profile: Profile

init(
Expand All @@ -36,6 +36,14 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable {
super.init(router: router)
}

deinit {
logger.log(
"MainMenuCoordinator - deinitialized",
level: .info,
category: .mainMenu
)
}

func start() {
logger.log(
"MainMenuCoordinator - started",
Expand Down Expand Up @@ -69,14 +77,23 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable {
router.popViewController(animated: true)
}

func removeCoordinatorFromParent() {
logger.log(
"MainMenuCoordinator - removing coordinator from parent",
level: .info,
category: .mainMenu
)
parentCoordinator?.didFinish(from: self)
}

func dismissMenuModal(animated: Bool) {
logger.log(
"MainMenuCoordinator - dismissing main menu",
level: .info,
category: .mainMenu
)
router.dismiss(animated: animated, completion: nil)
parentCoordinator?.didFinish(from: self)
removeCoordinatorFromParent()
}

func navigateTo(_ destination: MenuNavigationDestination, animated: Bool) {
Expand Down Expand Up @@ -119,7 +136,7 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable {
self.navigationHandler?.updateZoomPageBarVisibility()
}

self.parentCoordinator?.didFinish(from: self)
removeCoordinatorFromParent()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class MainMenuViewController: UIViewController,
currentTabInfo: menuState.currentTabInfo
)
)
coordinator?.dismissMenuModal(animated: true)
coordinator?.removeCoordinatorFromParent()
}

// MARK: - UISheetPresentationControllerDelegate
Expand Down