diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index fc5552856..ee7f35330 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -141,7 +141,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { } } - prefetchForHomeFragment() setupLeakCanary() startMetricsIfEnabled() setupPush() @@ -257,14 +256,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { // no-op, LeakCanary is disabled by default } - // This is for issue https://github.com/mozilla-mobile/fenix/issues/11660. We prefetch our info for startup - // so that we're sure that we have all the data available as our fragment is launched. - private fun prefetchForHomeFragment() { - StrictMode.allowThreadDiskReads().resetPoliciesAfter { - components.core.topSiteStorage.prefetch() - } - } - private fun setupPush() { // Sets the PushFeature as the singleton instance for push messages to go to. // We need the push feature setup here to deliver messages in the case where the service diff --git a/app/src/main/java/org/mozilla/fenix/ext/LiveData.kt b/app/src/main/java/org/mozilla/fenix/ext/LiveData.kt deleted file mode 100644 index 718385219..000000000 --- a/app/src/main/java/org/mozilla/fenix/ext/LiveData.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.ext - -import androidx.lifecycle.LiveData -import androidx.lifecycle.Observer - -/** - * Observe a LiveData once and unregister from it as soon as the live data returns a value - */ -fun LiveData.observeOnce(observer: (T) -> Unit) { - observeForever(object : Observer { - override fun onChanged(value: T) { - removeObserver(this) - observer(value) - } - }) -} 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 280bf4ca3..96d5bb0b6 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -68,7 +68,6 @@ import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AuthType import mozilla.components.concept.sync.OAuthAccount import mozilla.components.feature.tab.collections.TabCollection -import mozilla.components.feature.top.sites.TopSite import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.support.ktx.android.util.dpToPx import org.mozilla.fenix.BrowserDirection @@ -511,7 +510,6 @@ class HomeFragment : Fragment() { override fun onStart() { super.onStart() subscribeToTabCollections() - subscribeToTopSites() val context = requireContext() val components = context.components @@ -847,17 +845,6 @@ class HomeFragment : Fragment() { } } - private fun subscribeToTopSites(): Observer> { - return Observer> { topSites -> - requireComponents.core.topSiteStorage.cachedTopSites = topSites - context?.settings()?.preferences?.edit() - ?.putInt(getString(R.string.pref_key_top_sites_size), topSites.size)?.apply() - homeFragmentStore.dispatch(HomeFragmentAction.TopSitesChange(topSites)) - }.also { observer -> - requireComponents.core.topSiteStorage.getTopSites().observe(this, observer) - } - } - private fun registerCollectionStorageObserver() { requireComponents.core.tabCollectionStorage.register(collectionStorageObserver, this) }