Commit 0f0d56e6 authored by Sebastian Kaspari's avatar Sebastian Kaspari Committed by Emily Kager
Browse files

Issue #5208: Use new tab/collection restore API.

parent 4b804da8
......@@ -15,6 +15,7 @@ import mozilla.components.feature.media.ext.pauseIfPlaying
import mozilla.components.feature.media.ext.playIfPaused
import mozilla.components.feature.media.state.MediaStateMachine
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.tab.collections.ext.restore
import mozilla.components.feature.top.sites.TopSite
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity
......@@ -200,52 +201,36 @@ class DefaultSessionControlController(
override fun handleCollectionOpenTabClicked(tab: ComponentTab) {
invokePendingDeleteJobs()
val session = tab.restore(
context = activity,
engine = activity.components.core.engine,
tab = tab,
restoreSessionId = false
sessionManager.restore(
activity,
activity.components.core.engine,
tab,
onTabRestored = {
activity.openToBrowser(BrowserDirection.FromHome)
},
onFailure = {
activity.openToBrowserAndLoad(
searchTermOrURL = tab.url,
newTab = true,
from = BrowserDirection.FromHome
)
}
)
if (session == null) {
// We were unable to create a snapshot, so just load the tab instead
activity.openToBrowserAndLoad(
searchTermOrURL = tab.url,
newTab = true,
from = BrowserDirection.FromHome
)
} else {
sessionManager.add(
session,
true
)
activity.openToBrowser(BrowserDirection.FromHome)
}
metrics.track(Event.CollectionTabRestored)
}
override fun handleCollectionOpenTabsTapped(collection: TabCollection) {
invokePendingDeleteJobs()
collection.tabs.reversed().forEach {
val session = it.restore(
context = activity,
engine = activity.components.core.engine,
tab = it,
restoreSessionId = false
)
if (session == null) {
// We were unable to create a snapshot, so just load the tab instead
activity.components.useCases.tabsUseCases.addTab.invoke(it.url)
} else {
sessionManager.add(
session,
activity.components.core.sessionManager.selectedSession == null
)
sessionManager.restore(
activity,
activity.components.core.engine,
collection,
onFailure = { url ->
activity.components.useCases.tabsUseCases.addTab.invoke(url)
}
}
)
scrollToTheTop()
metrics.track(Event.CollectionAllTabsRestored)
......
......@@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object AndroidComponents {
const val VERSION = "38.0.20200326130056"
const val VERSION = "38.0.20200326160141"
}
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