Skip to content

Commit

Permalink
Bugfix FXIOS-10437 [Menu] Attempt fix for menu coordinator bug (#23458)
Browse files Browse the repository at this point in the history
* Attempt fix

* swifliiiiiint
  • Loading branch information
adudenamedruby authored Nov 29, 2024
1 parent f3e5d55 commit b421b9a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
11 changes: 7 additions & 4 deletions firefox-ios/Client/Coordinators/Browser/BrowserCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,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

0 comments on commit b421b9a

Please sign in to comment.