Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For 10503 - Update save to collection flow in tab tray #10523

Merged
merged 1 commit into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/src/main/java/org/mozilla/fenix/tabtray/TabTrayFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,28 @@ class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer,
val tabs = getListOfSessions()
val tabIds = tabs.map { it.id }.toList().toTypedArray()
val tabCollectionStorage = (activity as HomeActivity).components.core.tabCollectionStorage
val navController = findNavController()

val step = when {
// Show the SelectTabs fragment if there are multiple opened tabs to select which tabs
// you want to save to a collection.
tabs.size > 1 -> SaveCollectionStep.SelectTabs
// If there is an existing tab collection, show the SelectCollection fragment to save
// the selected tab to a collection of your choice.
tabCollectionStorage.cachedTabCollections.isNotEmpty() -> SaveCollectionStep.SelectCollection
// Show the NameCollection fragment to create a new collection for the selected tab.
else -> SaveCollectionStep.NameCollection
}

if (navController.currentDestination?.id == R.id.collectionCreationFragment) return

val directions = TabTrayFragmentDirections.actionTabTrayFragmentToCreateCollectionFragment(
tabIds = tabIds,
previousFragmentId = R.id.tabTrayFragment,
saveCollectionStep = step,
selectedTabIds = tabIds,
selectedTabCollectionId = -1
selectedTabIds = tabIds
)

view?.let {
findNavController().navigate(directions)
}
navController.nav(R.id.tabTrayFragment, directions)
}

override fun onStart() {
Expand Down