Skip to content

Commit

Permalink
Fix tab count
Browse files Browse the repository at this point in the history
  • Loading branch information
OrlaM committed Jan 24, 2024
1 parent e489e85 commit 2050596
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ struct TabTrayState: ScreenState, Equatable {
normalTabsCount: state.normalTabsCount,
hasSyncableAccount: state.hasSyncableAccount,
shareURL: shareURL)
case TabPanelAction.refreshTab(let tabModel, _):
// Only update the nomal tab count if the tabs being refreshed are not private
let isPrivate = tabModel.first?.isPrivate ?? false
let tabCount = isPrivate ? state.normalTabsCount : String(tabModel.count)
return TabTrayState(isPrivateMode: state.isPrivateMode,
selectedPanel: state.selectedPanel,
normalTabsCount: tabCount,
hasSyncableAccount: state.hasSyncableAccount)
default:
return state
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class TabTrayViewController: UIViewController,

func newState(state: TabTrayState) {
tabTrayState = state
countLabel.text = self.tabTrayState.normalTabsCount
updateTabCountImage(count: state.normalTabsCount)

if tabTrayState.shouldDismiss {
delegate?.didFinish()
Expand All @@ -272,6 +272,12 @@ class TabTrayViewController: UIViewController,
}
}

func updateTabCountImage(count: String) {
countLabel.text = count
segmentedControl.setImage(TabTrayPanelType.tabs.image!.overlayWith(image: countLabel),
forSegmentAt: 0)
}

// MARK: Themeable
func applyTheme() {
view.backgroundColor = themeManager.currentTheme.colors.layer1
Expand Down

0 comments on commit 2050596

Please sign in to comment.