diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2022-03-25 08:35:30 +0000 |
---|---|---|
committer | Abhishek Aggarwal <warabhishek@e.email> | 2022-03-25 08:35:30 +0000 |
commit | 3dd5b80faba18852f824d2a294dded8a0390d7da (patch) | |
tree | c20b5957108ce05e35f4703c5c1dd634f04d01c3 /app/src/main/java | |
parent | 61f492a49a70103fade1a486f1b7b0d836889927 (diff) |
Fix refresh dashboard on start #5147
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/features/dashboard/DashboardFragment.kt | 15 |
1 files changed, 12 insertions, 3 deletions
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) |