Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 7e49900a authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: reduce # of API calls on Home screen on config change

Moved API calls to MainActivityViewModel's init{} block. Having them on MainActivity's onCreate was causing unnecessary API calls on configuration changes.
parent d9aea6a8
Loading
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -98,11 +98,8 @@ class MainActivity : AppCompatActivity() {
            bottomNavigationView.selectedItemId = R.id.updatesFragment
        }


        viewModel.createNotificationChannels()



        viewModel.setupConnectivityManager(this.applicationContext)

        observeInternetConnections()
@@ -125,10 +122,6 @@ class MainActivity : AppCompatActivity() {
            showNoInternet()
        }

        viewModel.updateAppWarningList()
        viewModel.updateContentRatings()
        viewModel.fetchUpdatableSystemAppsList()

        observeEvents()

        checkGPlayLoginRequest(intent)
+6 −2
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ package foundation.e.apps.ui
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
@@ -69,6 +67,12 @@ class MainActivityViewModel @Inject constructor(
    private val systemAppsUpdatesRepository: SystemAppsUpdatesRepository,
) : ViewModel() {

    init {
        updateAppWarningList()
        updateContentRatings()
        fetchUpdatableSystemAppsList()
    }

    val tocStatus: LiveData<Boolean> = appLoungeDataStore.tocStatus.asLiveData()

    private val _purchaseAppLiveData: MutableLiveData<AppInstall> = MutableLiveData()