From 3dd5b80faba18852f824d2a294dded8a0390d7da Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 25 Mar 2022 08:35:30 +0000 Subject: Fix refresh dashboard on start #5147 --- .../features/dashboard/DashboardFragment.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/foundation/e') diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt index d2138af..f5cb2e1 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt @@ -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,11 +135,13 @@ class DashboardFragment : } } - private var updateUIJob: Job? = null override fun onResume() { super.onResume() - updateUIJob = lifecycleScope.launch { - viewModel.dashboardFeature.takeView(this, this@DashboardFragment) + + if (updateUIJob == null || updateUIJob?.isActive == false) { + updateUIJob = lifecycleScope.launch { + viewModel.dashboardFeature.takeView(this, this@DashboardFragment) + } } viewModel.submitAction(DashboardFeature.Action.FetchStatistics) -- cgit v1.2.1