diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index 24fd60105b..adb26abaae 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -25,6 +25,7 @@ import mozilla.components.feature.session.HistoryDelegate import mozilla.components.feature.session.bundling.SessionBundleStorage import mozilla.components.lib.crash.handler.CrashHandlerService import org.mozilla.fenix.AppRequestInterceptor +import org.mozilla.fenix.ext.components import org.mozilla.geckoview.GeckoRuntime import org.mozilla.geckoview.GeckoRuntimeSettings import java.util.concurrent.TimeUnit @@ -75,8 +76,9 @@ class Core(private val context: Context) { GeckoViewFetchClient(context, runtime) } - val sessionStorage by lazy { - SessionBundleStorage(context, bundleLifetime = Pair(BUNDLE_LIFETIME_IN_MINUTES, TimeUnit.MINUTES)) + val sessionStorage: SessionBundleStorage by lazy { + SessionBundleStorage(context, bundleLifetime = Pair(BUNDLE_LIFETIME_IN_MINUTES, TimeUnit.MINUTES), + engine = engine) } /** @@ -90,7 +92,7 @@ class Core(private val context: Context) { // Restore a previous, still active bundle. GlobalScope.launch(Dispatchers.Main) { val snapshot = async(Dispatchers.IO) { - sessionStorage.restore()?.restoreSnapshot(engine) + sessionStorage.restore()?.restoreSnapshot() } // There's an active bundle with a snapshot: Feed it into the SessionManager. diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index d871b09143..b3e4414b04 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -229,7 +229,7 @@ class HomeFragment : Fragment() { when (it) { is SessionsAction.Select -> { requireComponents.core.sessionStorage.archive(requireComponents.core.sessionManager) - it.archivedSession.bundle.restoreSnapshot(requireComponents.core.engine)?.apply { + it.archivedSession.bundle.restoreSnapshot()?.apply { requireComponents.core.sessionManager.restore(this) homeScrollView.smoothScrollTo(0, 0) } diff --git a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt index 202f790f6c..2b3f99730f 100644 --- a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt @@ -12,7 +12,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.main.session_bottom_sheet.view.* import org.mozilla.fenix.R -import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.home.sessions.ArchivedSession class SessionBottomSheetFragment : BottomSheetDialogFragment(), LayoutContainer { @@ -76,7 +75,7 @@ class SessionBottomSheetFragment : BottomSheetDialogFragment(), LayoutContainer is SessionType.Current -> it.titles is SessionType.Private -> it.titles is SessionType.Archived -> - it.archivedSession.bundle.restoreSnapshot(requireComponents.core.engine)?.let { snapshot -> + it.archivedSession.bundle.restoreSnapshot()?.let { snapshot -> snapshot.sessions.map { item -> item.session.title } } }