Bug 1879332 - ensure synced tabs includes the inactive property

(cherry picked from commit 5b559a4e485fa859e43e5eb3bbca95abbcbdb151)
fenix/124.1.0
Mark Hammond 2 months ago committed by mergify[bot]
parent 24fbc002f6
commit 382ca721c4

@ -43,6 +43,7 @@ import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.SyncAuth
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.maxActiveTime
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.StrictModeManager import org.mozilla.fenix.perf.StrictModeManager
import org.mozilla.fenix.perf.lazyMonitored import org.mozilla.fenix.perf.lazyMonitored
@ -143,7 +144,7 @@ class BackgroundServices(
} }
val syncedTabsStorage by lazyMonitored { val syncedTabsStorage by lazyMonitored {
SyncedTabsStorage(accountManager, context.components.core.store, remoteTabsStorage.value) SyncedTabsStorage(accountManager, context.components.core.store, remoteTabsStorage.value, maxActiveTime)
} }
val syncedTabsAutocompleteProvider by lazyMonitored { val syncedTabsAutocompleteProvider by lazyMonitored {
SyncedTabsAutocompleteProvider(syncedTabsStorage) SyncedTabsAutocompleteProvider(syncedTabsStorage)

@ -626,5 +626,6 @@ private fun generateFakeSyncedTab(tabName: String, tabUrl: String): SyncedTabsLi
history = listOf(TabEntry(tabName, tabUrl, null)), history = listOf(TabEntry(tabName, tabUrl, null)),
active = 0, active = 0,
lastUsed = 0L, lastUsed = 0L,
inactive = false,
), ),
) )

@ -6,12 +6,12 @@ package org.mozilla.fenix.tabstray.browser
import mozilla.components.browser.state.state.TabPartition import mozilla.components.browser.state.state.TabPartition
import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.isActive
import mozilla.components.browser.tabstray.TabsTray import mozilla.components.browser.tabstray.TabsTray
import mozilla.components.feature.tabs.tabstray.TabsFeature import mozilla.components.feature.tabs.tabstray.TabsFeature
import org.mozilla.fenix.ext.maxActiveTime import org.mozilla.fenix.ext.maxActiveTime
import org.mozilla.fenix.tabstray.TabsTrayAction import org.mozilla.fenix.tabstray.TabsTrayAction
import org.mozilla.fenix.tabstray.TabsTrayStore import org.mozilla.fenix.tabstray.TabsTrayStore
import org.mozilla.fenix.tabstray.ext.isActive
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
/** /**

@ -5,14 +5,9 @@
package org.mozilla.fenix.tabstray.ext package org.mozilla.fenix.tabstray.ext
import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.isActive
import mozilla.components.support.ktx.kotlin.trimmed import mozilla.components.support.ktx.kotlin.trimmed
fun TabSessionState.isActive(maxActiveTime: Long): Boolean {
val lastActiveTime = maxOf(lastAccess, createdAt)
val now = System.currentTimeMillis()
return (now - lastActiveTime <= maxActiveTime)
}
/** /**
* Returns true if the [TabSessionState] has a search term. * Returns true if the [TabSessionState] has a search term.
*/ */

@ -309,5 +309,6 @@ private fun generateFakeTab(tabName: String, tabUrl: String): SyncedTabsListItem
history = listOf(TabEntry(tabName, tabUrl, null)), history = listOf(TabEntry(tabName, tabUrl, null)),
active = 0, active = 0,
lastUsed = 0L, lastUsed = 0L,
inactive = false,
), ),
) )

@ -43,6 +43,7 @@ class SyncedDeviceTabsTest {
), ),
active = 0, active = 0,
lastUsed = 0L, lastUsed = 0L,
inactive = false,
), ),
), ),
) )
@ -64,6 +65,7 @@ class SyncedDeviceTabsTest {
), ),
active = 0, active = 0,
lastUsed = 0L, lastUsed = 0L,
inactive = false,
), ),
Tab( Tab(
history = listOf( history = listOf(
@ -75,6 +77,7 @@ class SyncedDeviceTabsTest {
), ),
active = 0, active = 0,
lastUsed = 0L, lastUsed = 0L,
inactive = false,
), ),
), ),
) )

Loading…
Cancel
Save