@ -12,19 +12,22 @@ import mozilla.components.browser.tabstray.TabViewHolder
import mozilla.components.feature.tabs.tabstray.TabsFeature
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.tabstray.ext.browserAdapter
import org.mozilla.fenix.tabstray.ext.inactiveTabsAdapter
import org.mozilla.fenix.tabstray.ext.isNormalTabActive
import org.mozilla.fenix.tabstray.ext.isNormalTabActiveWithSearchTerm
import org.mozilla.fenix.tabstray.ext.isNormalTabActiveWithoutSearchTerm
import org.mozilla.fenix.tabstray.ext.isNormalTabWithoutSearchTerm
import org.mozilla.fenix.tabstray.ext.isNormalTabWithSearchTerm
import org.mozilla.fenix.tabstray.ext.isNormalTabInactive
import org.mozilla.fenix.tabstray.ext.isNormalTabActiveWithSearchTerm
import org.mozilla.fenix.tabstray.ext.tabGroupAdapter
import java.util.concurrent.TimeUnit
/ * *
* The time until which a tab is considered in - active ( in days ) .
* /
const val DEFAULT _ACTIVE _DAYS = 4L
const val DEFAULT _ACTIVE _DAYS = 1 4L
/ * *
* The maximum time from when a tab was created or accessed until it is considered " inactive " .
@ -41,34 +44,41 @@ class NormalBrowserTrayList @JvmOverloads constructor(
override val tabsFeature by lazy {
val tabsAdapter = concatAdapter . browserAdapter
val inactiveTabsEnabled = context . settings ( ) . inactiveTabsAreEnabled
val tabFilter : ( TabSessionState ) -> Boolean = {
when {
FeatureFlags . tabGroupFeature && inactiveTabsEnabled ->
it . isNormalTabActiveWithoutSearchTerm ( maxActiveTime )
inactiveTabsEnabled -> it . isNormalTabActive ( maxActiveTime )
FeatureFlags . tabGroupFeature -> it . isNormalTabWithoutSearchTerm ( )
else -> ! it . content . private
}
}
TabsFeature (
tabsAdapter ,
context . components . core . store ,
selectTabUseCase ,
removeTabUseCase ,
{ state ->
if ( ! FeatureFlags . inactiveTabs ) {
return @TabsFeature ! state . content . private
}
if ( ! FeatureFlags . tabGroupFeature ) {
state . isNormalTabActive ( maxActiveTime )
} else {
state . isNormalTabActiveWithoutSearchTerm ( maxActiveTime )
}
} ,
tabFilter ,
{ }
)
}
private val searchTermFeature by lazy {
val store = context . components . core . store
val tabFilter : ( TabSessionState ) -> Boolean = filter @ {
if ( ! FeatureFlags . tabGroupFeature ) {
return @filter false
val inactiveTabsEnabled = context . settings ( ) . inactiveTabsAreEnabled
val tabFilter : ( TabSessionState ) -> Boolean = {
when {
FeatureFlags . tabGroupFeature && inactiveTabsEnabled -> it . isNormalTabActiveWithSearchTerm ( maxActiveTime )
FeatureFlags . tabGroupFeature -> it . isNormalTabWithSearchTerm ( )
else -> false
}
it . isNormalTabActiveWithSearchTerm ( maxActiveTime )
}
val tabsAdapter = concatAdapter . tabGroupAdapter
@ -89,7 +99,7 @@ class NormalBrowserTrayList @JvmOverloads constructor(
private val inactiveFeature by lazy {
val store = context . components . core . store
val tabFilter : ( TabSessionState ) -> Boolean = filter @ {
if ( ! FeatureFlags . inactiveTabs ) {
if ( ! context . settings ( ) . inactiveTabsAreEnabled ) {
return @filter false
}
it . isNormalTabInactive ( maxActiveTime )