Unverified Commit ef5846dc authored by Mugurell's avatar Mugurell Committed by GitHub
Browse files

For #16614 - Ensure a stable order for the items in tabs tray. (#16618)

Items should follow the following ordering:
- current session open tabs
- collections options - currently the "Select tabs" button
- synced tabs items

This order should also be kept after returning from Multiselect mode.
parent 5f9de1e2
......@@ -21,7 +21,6 @@ import mozilla.components.browser.storage.sync.SyncedDeviceTabs
import mozilla.components.feature.syncedtabs.view.SyncedTabsView
import mozilla.components.lib.state.ext.flowScoped
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.sync.ListenerDelegate
import org.mozilla.fenix.sync.SyncedTabsAdapter
import org.mozilla.fenix.sync.ext.toAdapterList
......@@ -51,11 +50,7 @@ class SyncedTabsController(
.collect { mode ->
when (mode) {
is TabTrayDialogFragmentState.Mode.Normal -> {
if (view.context.settings().gridTabView) {
concatAdapter.addAdapter(adapter)
} else {
concatAdapter.addAdapter(0, adapter)
}
}
is TabTrayDialogFragmentState.Mode.MultiSelect -> {
concatAdapter.removeAdapter(adapter)
......
......@@ -192,13 +192,8 @@ class TabTrayView(
tabsAdapter.tabTrayInteractor = interactor
tabsAdapter.onTabsUpdated = {
if (view.context.settings().gridTabView) {
concatAdapter.addAdapter(syncedTabsController.adapter)
concatAdapter.addAdapter(collectionsButtonAdapter)
} else {
concatAdapter.addAdapter(syncedTabsController.adapter)
concatAdapter.addAdapter(collectionsButtonAdapter)
}
if (hasAccessibilityEnabled) {
tabsAdapter.notifyItemRangeChanged(0, tabs.size)
......
......@@ -25,7 +25,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.sync.SyncedTabsViewHolder
import org.mozilla.fenix.tabtray.TabTrayDialogFragmentAction.EnterMultiSelectMode
......@@ -56,7 +55,6 @@ class SyncedTabsControllerTest {
concatAdapter = mockk()
every { concatAdapter.addAdapter(any()) } returns true
every { concatAdapter.addAdapter(any(), any()) } returns true
every { concatAdapter.removeAdapter(any()) } returns true
store = TabTrayDialogFragmentStore(
......@@ -130,22 +128,11 @@ class SyncedTabsControllerTest {
@Test
fun `concatAdapter updated on mode changes`() = testDispatcher.runBlockingTest {
// When returning from Multiselect while in grid view the adapter should be added at the end
every { view.context.settings().gridTabView } returns true
store.dispatch(EnterMultiSelectMode).joinBlocking()
verify { concatAdapter.removeAdapter(any()) }
store.dispatch(ExitMultiSelectMode).joinBlocking()
// When returning from Multiselect the adapter should be added at the end
verify { concatAdapter.addAdapter(any()) }
// When returning from Multiselect while in list view the adapter should be added at the front
every { view.context.settings().gridTabView } returns false
store.dispatch(EnterMultiSelectMode).joinBlocking()
verify { concatAdapter.removeAdapter(any()) }
store.dispatch(ExitMultiSelectMode).joinBlocking()
verify { concatAdapter.addAdapter(0, any()) }
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment