Skip to content

Commit

Permalink
For mozilla-mobile#15632: Improve checking open tabs logic to show co…
Browse files Browse the repository at this point in the history
…llection button.

Check now considers selected tab tray mode.
  • Loading branch information
mcarare authored and gabrielluong committed Oct 3, 2020
1 parent ec3595d commit 07748f6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt
Expand Up @@ -100,6 +100,14 @@ class TabTrayView(

private val components = container.context.components

private val checkOpenTabs = {
if (isPrivateModeSelected) {
view.context.components.core.store.state.privateTabs.isNotEmpty()
} else {
view.context.components.core.store.state.normalTabs.isNotEmpty()
}
}

init {
components.analytics.metrics.track(Event.TabsTrayOpened)

Expand Down Expand Up @@ -214,14 +222,9 @@ class TabTrayView(
tabTrayItemMenu =
TabTrayItemMenu(
context = view.context,
shouldShowSaveToCollection = { tabs.isNotEmpty() && view.tab_layout.selectedTabPosition == 0 },
hasOpenTabs = {
if (isPrivateModeSelected) {
view.context.components.core.store.state.privateTabs.isNotEmpty()
} else {
view.context.components.core.store.state.normalTabs.isNotEmpty()
}
}) {
shouldShowSaveToCollection = { checkOpenTabs.invoke() && view.tab_layout.selectedTabPosition == 0 },
hasOpenTabs = checkOpenTabs
) {
when (it) {
is TabTrayItemMenu.Item.ShareAllTabs -> interactor.onShareTabsClicked(
isPrivateModeSelected
Expand Down

0 comments on commit 07748f6

Please sign in to comment.