From 49961d7dda6b265d38f764408d5861628d7e5dbf Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 21 Nov 2024 11:45:50 +0100 Subject: [PATCH] fix: if no home data is displayed also load data again --- app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt | 4 +++- app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index 3ff38c4f0..11685cc09 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -186,7 +186,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun loadData(authObjectList: List) { - if (homeViewModel.haveSourcesChanged()) { + if (shouldLoadData()) { showLoadingUI() homeViewModel.loadData(authObjectList, viewLifecycleOwner) { _ -> clearAndRestartGPlayLogin() @@ -195,6 +195,8 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } } + private fun shouldLoadData() = homeViewModel.haveSourcesChanged() || !homeViewModel.hasData() + override fun showLoadingUI() { binding.shimmerLayout.startShimmer() binding.shimmerLayout.visibility = View.VISIBLE diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index 30ecfb9bd..861527a73 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -57,6 +57,10 @@ class HomeViewModel @Inject constructor( private var previousSources = emptyList() + fun hasData(): Boolean { + return homeScreenData.value?.data?.isNotEmpty() ?: false + } + fun loadData( authObjectList: List, lifecycleOwner: LifecycleOwner, -- GitLab