diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuConfigurationUtility.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuConfigurationUtility.swift index 041576ba7473..fdd2a8fcf15f 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuConfigurationUtility.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuConfigurationUtility.swift @@ -48,7 +48,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.newTab) + actionType: MainMenuActionType.show, + navigationDestination: .newTab ) ) } @@ -65,7 +66,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.newPrivateTab) + actionType: MainMenuActionType.show, + navigationDestination: .newPrivateTab ) ) } @@ -112,7 +114,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.findInPage) + actionType: MainMenuActionType.show, + navigationDestination: .findInPage ) ) } @@ -129,9 +132,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show( - .detailsView(with: getToolsSubmenu(with: uuid)) - ) + actionType: MainMenuActionType.show, + navigationDestination: .detailsView(with: getToolsSubmenu(with: uuid)) ) ) } @@ -148,9 +150,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show( - .detailsView(with: getSaveSubmenu(with: uuid)) - ) + actionType: MainMenuActionType.show, + navigationDestination: .detailsView(with: getSaveSubmenu(with: uuid)) ) ) } @@ -402,7 +403,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.bookmarks) + actionType: MainMenuActionType.show, + navigationDestination: .bookmarks ) ) } @@ -419,7 +421,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.history) + actionType: MainMenuActionType.show, + navigationDestination: .history ) ) } @@ -436,7 +439,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.downloads) + actionType: MainMenuActionType.show, + navigationDestination: .downloads ) ) } @@ -453,7 +457,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.passwords) + actionType: MainMenuActionType.show, + navigationDestination: .passwords ) ) } @@ -479,7 +484,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.customizeHomepage) + actionType: MainMenuActionType.show, + navigationDestination: .customizeHomepage ) ) } @@ -499,7 +505,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.goToURL(SupportUtils.URLForWhatsNew)) + actionType: MainMenuActionType.show, + navigationDestination: .goToURL(SupportUtils.URLForWhatsNew) ) ) } @@ -519,7 +526,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.goToURL(SupportUtils.URLForGetHelp)) + actionType: MainMenuActionType.show, + navigationDestination: .goToURL(SupportUtils.URLForGetHelp) ) ) } @@ -536,7 +544,8 @@ struct MainMenuConfigurationUtility: Equatable { store.dispatch( MainMenuAction( windowUUID: uuid, - actionType: MainMenuActionType.show(.settings) + actionType: MainMenuActionType.show, + navigationDestination: .settings ) ) } diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuAction.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuAction.swift index 1b371fa7138f..9119bb5fd31c 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuAction.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuAction.swift @@ -8,7 +8,14 @@ import MenuKit import Redux final class MainMenuAction: Action { - override init(windowUUID: WindowUUID, actionType: any ActionType) { + var navigationDestination: MainMenuNavigationDestination? + + init( + windowUUID: WindowUUID, + actionType: any ActionType, + navigationDestination: MainMenuNavigationDestination? = nil + ) { + self.navigationDestination = navigationDestination super.init(windowUUID: windowUUID, actionType: actionType) } } @@ -19,7 +26,7 @@ enum MainMenuActionType: ActionType { case mainMenuDidAppear case toggleNightMode case closeMenu - case show(MainMenuNavigationDestination) + case show case toggleUserAgent } diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift index cc65eecc8747..5e3788e1aefe 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift @@ -85,12 +85,14 @@ struct MainMenuState: ScreenState, Equatable { ), currentTabInfo: info ) - case MainMenuActionType.show(let destination): + case MainMenuActionType.show: + guard let menuAction = action as? MainMenuAction else { return state } + return MainMenuState( windowUUID: state.windowUUID, menuElements: state.menuElements, currentTabInfo: state.currentTabInfo, - navigationDestination: destination + navigationDestination: menuAction.navigationDestination ) case MainMenuActionType.toggleUserAgent, MainMenuActionType.closeMenu: diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/MainMenu/MainMenuStateTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/MainMenu/MainMenuStateTests.swift index 99daa6ebc22e..1ca548d62aba 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/MainMenu/MainMenuStateTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/MainMenu/MainMenuStateTests.swift @@ -62,7 +62,8 @@ final class MainMenuStateTests: XCTestCase { initialState, MainMenuAction( windowUUID: .XCTestDefaultUUID, - actionType: MainMenuActionType.show(destination) + actionType: MainMenuActionType.show, + navigationDestination: destination ) )