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 ...@@ -21,7 +21,6 @@ import mozilla.components.browser.storage.sync.SyncedDeviceTabs
import mozilla.components.feature.syncedtabs.view.SyncedTabsView import mozilla.components.feature.syncedtabs.view.SyncedTabsView
import mozilla.components.lib.state.ext.flowScoped import mozilla.components.lib.state.ext.flowScoped
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged 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.ListenerDelegate
import org.mozilla.fenix.sync.SyncedTabsAdapter import org.mozilla.fenix.sync.SyncedTabsAdapter
import org.mozilla.fenix.sync.ext.toAdapterList import org.mozilla.fenix.sync.ext.toAdapterList
...@@ -51,11 +50,7 @@ class SyncedTabsController( ...@@ -51,11 +50,7 @@ class SyncedTabsController(
.collect { mode -> .collect { mode ->
when (mode) { when (mode) {
is TabTrayDialogFragmentState.Mode.Normal -> { is TabTrayDialogFragmentState.Mode.Normal -> {
if (view.context.settings().gridTabView) { concatAdapter.addAdapter(adapter)
concatAdapter.addAdapter(adapter)
} else {
concatAdapter.addAdapter(0, adapter)
}
} }
is TabTrayDialogFragmentState.Mode.MultiSelect -> { is TabTrayDialogFragmentState.Mode.MultiSelect -> {
concatAdapter.removeAdapter(adapter) concatAdapter.removeAdapter(adapter)
......
...@@ -192,13 +192,8 @@ class TabTrayView( ...@@ -192,13 +192,8 @@ class TabTrayView(
tabsAdapter.tabTrayInteractor = interactor tabsAdapter.tabTrayInteractor = interactor
tabsAdapter.onTabsUpdated = { tabsAdapter.onTabsUpdated = {
if (view.context.settings().gridTabView) { concatAdapter.addAdapter(collectionsButtonAdapter)
concatAdapter.addAdapter(syncedTabsController.adapter) concatAdapter.addAdapter(syncedTabsController.adapter)
concatAdapter.addAdapter(collectionsButtonAdapter)
} else {
concatAdapter.addAdapter(syncedTabsController.adapter)
concatAdapter.addAdapter(collectionsButtonAdapter)
}
if (hasAccessibilityEnabled) { if (hasAccessibilityEnabled) {
tabsAdapter.notifyItemRangeChanged(0, tabs.size) tabsAdapter.notifyItemRangeChanged(0, tabs.size)
......
...@@ -25,7 +25,6 @@ import org.junit.Rule ...@@ -25,7 +25,6 @@ import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.sync.SyncedTabsViewHolder import org.mozilla.fenix.sync.SyncedTabsViewHolder
import org.mozilla.fenix.tabtray.TabTrayDialogFragmentAction.EnterMultiSelectMode import org.mozilla.fenix.tabtray.TabTrayDialogFragmentAction.EnterMultiSelectMode
...@@ -56,7 +55,6 @@ class SyncedTabsControllerTest { ...@@ -56,7 +55,6 @@ class SyncedTabsControllerTest {
concatAdapter = mockk() concatAdapter = mockk()
every { concatAdapter.addAdapter(any()) } returns true every { concatAdapter.addAdapter(any()) } returns true
every { concatAdapter.addAdapter(any(), any()) } returns true
every { concatAdapter.removeAdapter(any()) } returns true every { concatAdapter.removeAdapter(any()) } returns true
store = TabTrayDialogFragmentStore( store = TabTrayDialogFragmentStore(
...@@ -130,22 +128,11 @@ class SyncedTabsControllerTest { ...@@ -130,22 +128,11 @@ class SyncedTabsControllerTest {
@Test @Test
fun `concatAdapter updated on mode changes`() = testDispatcher.runBlockingTest { 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() store.dispatch(EnterMultiSelectMode).joinBlocking()
verify { concatAdapter.removeAdapter(any()) } verify { concatAdapter.removeAdapter(any()) }
store.dispatch(ExitMultiSelectMode).joinBlocking() store.dispatch(ExitMultiSelectMode).joinBlocking()
// When returning from Multiselect the adapter should be added at the end
verify { concatAdapter.addAdapter(any()) } 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