Skip to content

Commit

Permalink
stop dispatching urlDidChange on orientation change
Browse files Browse the repository at this point in the history
  • Loading branch information
MattLichtenstein committed Oct 14, 2024
1 parent a46eb23 commit 70e7547
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,17 +453,11 @@ class BrowserViewController: UIViewController,
view.layoutSubviews()

if let tab = tabManager.selectedTab,
let webView = tab.webView {
let webView = tab.webView,
!isToolbarRefactorEnabled {
updateURLBarDisplayURL(tab)

if isToolbarRefactorEnabled {
dispatchBackForwardToolbarAction(canGoBack: webView.canGoBack,
canGoForward: webView.canGoForward,
windowUUID: windowUUID)
} else {
navigationToolbar.updateBackStatus(webView.canGoBack)
navigationToolbar.updateForwardStatus(webView.canGoForward)
}
navigationToolbar.updateBackStatus(webView.canGoBack)
navigationToolbar.updateForwardStatus(webView.canGoForward)
}
}

Expand Down Expand Up @@ -2340,14 +2334,16 @@ class BrowserViewController: UIViewController,
/// This requires an update of the toolbars.
private func updateToolbarStateTraitCollectionIfNecessary(_ newCollection: UITraitCollection) {
let showTopTabs = ToolbarHelper().shouldShowTopTabs(for: newCollection)
let showNavToolbar = ToolbarHelper().shouldShowNavigationToolbar(for: newCollection)

// Only dispatch action when the value of top tabs being shown is different from what is saved in the state
// to avoid having the toolbar re-displayed
guard let toolbarState = store.state.screenState(ToolbarState.self, for: .toolbar, window: windowUUID),
toolbarState.isShowingTopTabs != showTopTabs
toolbarState.isShowingTopTabs != showTopTabs || toolbarState.isShowingNavigationToolbar != showNavToolbar
else { return }

let action = ToolbarAction(
isShowingNavigationToolbar: showNavToolbar,
isShowingTopTabs: showTopTabs,
windowUUID: windowUUID,
actionType: ToolbarActionType.traitCollectionDidChange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ struct ToolbarState: ScreenState, Equatable {
isPrivateMode: state.isPrivateMode,
addressToolbar: AddressBarState.reducer(state.addressToolbar, toolbarAction),
navigationToolbar: NavigationBarState.reducer(state.navigationToolbar, toolbarAction),
isShowingNavigationToolbar: state.isShowingNavigationToolbar,
isShowingNavigationToolbar: toolbarAction.isShowingNavigationToolbar ?? state.isShowingNavigationToolbar,
isShowingTopTabs: toolbarAction.isShowingTopTabs ?? state.isShowingTopTabs,
canGoBack: state.canGoBack,
canGoForward: state.canGoForward,
Expand Down

0 comments on commit 70e7547

Please sign in to comment.