Skip to content

Commit

Permalink
Issue mozilla-mobile#20637 - Fixed bug causing the tabs tray to scrol…
Browse files Browse the repository at this point in the history
…l to the wrong tab when opened
  • Loading branch information
MozillaNoah authored and mergify[bot] committed Sep 9, 2021
1 parent 70247e9 commit b3a86e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import org.mozilla.fenix.sync.SyncedTabsAdapter
import org.mozilla.fenix.tabstray.browser.BrowserTabsAdapter
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
import org.mozilla.fenix.tabstray.browser.InactiveTabsAdapter
import org.mozilla.fenix.tabstray.browser.maxActiveTime
import org.mozilla.fenix.tabstray.ext.isNormalTabActive
import org.mozilla.fenix.tabstray.syncedtabs.TabClickDelegate
import org.mozilla.fenix.tabstray.viewholders.AbstractPageViewHolder
import org.mozilla.fenix.tabstray.viewholders.NormalBrowserPageViewHolder
Expand Down Expand Up @@ -53,7 +55,7 @@ class TrayPagerAdapter(
itemView,
store,
interactor,
browserStore.state.normalTabs.indexOf(selectedTab)
browserStore.state.normalTabs.filter { it.isNormalTabActive(maxActiveTime) }.indexOf(selectedTab)
)
}
PrivateBrowserPageViewHolder.LAYOUT_ID -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import java.util.concurrent.TimeUnit
*/
const val DEFAULT_ACTIVE_DAYS = 4L

/**
* The maximum time from when a tab was created or accessed until it is considered "inactive".
*/
val maxActiveTime = TimeUnit.DAYS.toMillis(DEFAULT_ACTIVE_DAYS)

class NormalBrowserTrayList @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AbstractBrowserTrayList(context, attrs, defStyleAttr) {

/**
* The maximum time from when a tab was created or accessed until it is considered "inactive".
*/
var maxActiveTime = TimeUnit.DAYS.toMillis(DEFAULT_ACTIVE_DAYS)

private val concatAdapter by lazy { adapter as ConcatAdapter }

override val tabsFeature by lazy {
Expand Down

0 comments on commit b3a86e9

Please sign in to comment.