From 07748f69b75144e8e247b742f66a756f999cb299 Mon Sep 17 00:00:00 2001 From: mcarare Date: Fri, 2 Oct 2020 16:20:43 +0300 Subject: [PATCH] For #15632: Improve checking open tabs logic to show collection button. Check now considers selected tab tray mode. --- .../org/mozilla/fenix/tabtray/TabTrayView.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt index 924496c43e..da12846b9a 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt @@ -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) @@ -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