Issue #20704: Use AppStore for inactive expanded state
This commit is contained in:
parent
9cef9357b1
commit
8c43ccc0f6
|
@ -388,7 +388,8 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|||
browserInteractor,
|
||||
navigationInteractor,
|
||||
trayInteractor,
|
||||
requireComponents.core.store
|
||||
requireComponents.core.store,
|
||||
requireComponents.appStore
|
||||
)
|
||||
isUserInputEnabled = false
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.annotation.VisibleForTesting
|
|||
import androidx.recyclerview.widget.ConcatAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import org.mozilla.fenix.components.AppStore
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.sync.SyncedTabsAdapter
|
||||
import org.mozilla.fenix.tabstray.browser.BrowserTabsAdapter
|
||||
|
@ -24,13 +25,15 @@ import org.mozilla.fenix.tabstray.viewholders.NormalBrowserPageViewHolder
|
|||
import org.mozilla.fenix.tabstray.viewholders.PrivateBrowserPageViewHolder
|
||||
import org.mozilla.fenix.tabstray.viewholders.SyncedTabsPageViewHolder
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class TrayPagerAdapter(
|
||||
@VisibleForTesting internal val context: Context,
|
||||
@VisibleForTesting internal val tabsTrayStore: TabsTrayStore,
|
||||
@VisibleForTesting internal val browserInteractor: BrowserTrayInteractor,
|
||||
@VisibleForTesting internal val navInteractor: NavigationInteractor,
|
||||
@VisibleForTesting internal val interactor: TabsTrayInteractor,
|
||||
@VisibleForTesting internal val browserStore: BrowserStore
|
||||
@VisibleForTesting internal val browserStore: BrowserStore,
|
||||
@VisibleForTesting internal val appStore: AppStore
|
||||
) : RecyclerView.Adapter<AbstractPageViewHolder>() {
|
||||
|
||||
/**
|
||||
|
@ -67,6 +70,7 @@ class TrayPagerAdapter(
|
|||
itemView,
|
||||
tabsTrayStore,
|
||||
browserStore,
|
||||
appStore,
|
||||
interactor
|
||||
)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ sealed class InactiveTabViewHolder(itemView: View) : RecyclerView.ViewHolder(ite
|
|||
|
||||
init {
|
||||
itemView.apply {
|
||||
isActivated = InactiveTabsState.isExpanded
|
||||
isActivated = itemView.context.components.appStore.state.inactiveTabsExpanded
|
||||
|
||||
correctHeaderBorder(isActivated)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.ListAdapter
|
|||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.browser.tabstray.TabsTray
|
||||
import org.mozilla.fenix.components.Components
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabViewHolder.AutoCloseDialogHolder
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabViewHolder.FooterHolder
|
||||
|
@ -92,7 +93,7 @@ class InactiveTabsAdapter(
|
|||
}
|
||||
|
||||
// If we have items, but we should be in a collapsed state.
|
||||
if (!InactiveTabsState.isExpanded) {
|
||||
if (!context.components.appStore.state.inactiveTabsExpanded) {
|
||||
submitList(listOf(Item.Header))
|
||||
return
|
||||
}
|
||||
|
|
|
@ -7,11 +7,14 @@ package org.mozilla.fenix.tabstray.browser
|
|||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.browser.tabstray.TabsTray
|
||||
import org.mozilla.fenix.components.appstate.AppAction
|
||||
import org.mozilla.fenix.components.AppStore
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
|
||||
class InactiveTabsController(
|
||||
private val browserStore: BrowserStore,
|
||||
private val appStore: AppStore,
|
||||
private val tabFilter: (TabSessionState) -> Boolean,
|
||||
private val tray: TabsTray,
|
||||
private val metrics: MetricController
|
||||
|
@ -21,7 +24,7 @@ class InactiveTabsController(
|
|||
* the title showing.
|
||||
*/
|
||||
fun updateCardExpansion(isExpanded: Boolean) {
|
||||
InactiveTabsState.isExpanded = isExpanded
|
||||
appStore.dispatch(AppAction.UpdateInactiveExpanded(isExpanded))
|
||||
|
||||
metrics.track(
|
||||
when (isExpanded) {
|
||||
|
|
|
@ -52,6 +52,7 @@ class NormalBrowserTrayList @JvmOverloads constructor(
|
|||
DefaultInactiveTabsInteractor(
|
||||
InactiveTabsController(
|
||||
context.components.core.store,
|
||||
context.components.appStore,
|
||||
inactiveTabsFilter,
|
||||
concatAdapter.inactiveTabsAdapter,
|
||||
context.components.analytics.metrics
|
||||
|
|
|
@ -13,12 +13,13 @@ import mozilla.components.browser.state.selector.selectedNormalTab
|
|||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.appstate.AppAction
|
||||
import org.mozilla.fenix.components.AppStore
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.selection.SelectionHolder
|
||||
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
import org.mozilla.fenix.tabstray.TabsTrayStore
|
||||
import org.mozilla.fenix.tabstray.browser.containsTabId
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabsState
|
||||
import org.mozilla.fenix.tabstray.browser.maxActiveTime
|
||||
import org.mozilla.fenix.tabstray.ext.browserAdapter
|
||||
import org.mozilla.fenix.tabstray.ext.defaultBrowserLayoutColumns
|
||||
|
@ -38,6 +39,7 @@ class NormalBrowserPageViewHolder(
|
|||
containerView: View,
|
||||
private val tabsTrayStore: TabsTrayStore,
|
||||
private val browserStore: BrowserStore,
|
||||
private val appStore: AppStore,
|
||||
interactor: TabsTrayInteractor,
|
||||
) : AbstractBrowserPageViewHolder(containerView, tabsTrayStore, interactor), SelectionHolder<TabSessionState> {
|
||||
|
||||
|
@ -87,7 +89,9 @@ class NormalBrowserPageViewHolder(
|
|||
if (inactiveTabsAreEnabled && selectedTab.isNormalTabInactive(maxActiveTime)) {
|
||||
val inactiveTabsList = browserStore.state.inactiveTabs
|
||||
// We want to expand the inactive section first before we want to fire our scroll observer.
|
||||
InactiveTabsState.isExpanded = true
|
||||
|
||||
appStore.dispatch(AppAction.UpdateInactiveExpanded(true))
|
||||
|
||||
inactiveTabAdapter.observeFirstInsert {
|
||||
inactiveTabsList.forEachIndexed { tabIndex, item ->
|
||||
if (item.id == selectedTab.id) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user