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

Commit 3dd5b80f authored by Guillaume Jacquart's avatar Guillaume Jacquart Committed by Abhishek Aggarwal
Browse files

Fix refresh dashboard on start #5147

parent 61f492a4
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -63,8 +63,15 @@ class DashboardFragment :
    private lateinit var graphHolder: GraphHolder
    private lateinit var binding: FragmentDashboardBinding

    private var updateUIJob: Job? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        updateUIJob = lifecycleScope.launchWhenStarted {
            viewModel.dashboardFeature.takeView(this, this@DashboardFragment)
        }

        lifecycleScope.launchWhenStarted {
            viewModel.dashboardFeature.singleEvents.collect { event ->
                when (event) {
@@ -128,12 +135,14 @@ class DashboardFragment :
        }
    }

    private var updateUIJob: Job? = null
    override fun onResume() {
        super.onResume()

        if (updateUIJob == null || updateUIJob?.isActive == false) {
            updateUIJob = lifecycleScope.launch {
                viewModel.dashboardFeature.takeView(this, this@DashboardFragment)
            }
        }

        viewModel.submitAction(DashboardFeature.Action.FetchStatistics)
    }