From d818054f6133f134c8afd0dadd4e6af6fcb47cc2 Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 14 Jun 2024 10:21:08 +0200 Subject: [PATCH] fix: [ANDROAPP-6131] refresh data on resume Signed-off-by: Pablo --- .../programEventDetail/eventList/EventListFragment.kt | 8 +++++++- .../programEventDetail/eventList/EventListViewModel.kt | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListFragment.kt b/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListFragment.kt index 69de9cf496b..38dd14eef71 100644 --- a/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListFragment.kt @@ -30,6 +30,8 @@ class EventListFragment : FragmentGlobalAbstract() { @Inject lateinit var cardMapper: EventCardMapper + val eventListViewModel by viewModels { eventListViewModelFactory } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -43,7 +45,6 @@ class EventListFragment : FragmentGlobalAbstract() { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { val workingListViewModel by viewModels { workingListViewModelFactory } - val eventListViewModel by viewModels { eventListViewModelFactory } val programEventsViewModel by activityViewModels() val cardClicked by eventListViewModel.onEventCardClick.collectAsState(null) val syncClicked by eventListViewModel.onSyncClick.collectAsState(null) @@ -65,4 +66,9 @@ class EventListFragment : FragmentGlobalAbstract() { } } } + + override fun onResume() { + super.onResume() + eventListViewModel.refreshData() + } } diff --git a/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListViewModel.kt b/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListViewModel.kt index 47aafcd3d98..741f3c4f3a1 100644 --- a/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListViewModel.kt +++ b/app/src/main/java/org/dhis2/usescases/programEventDetail/eventList/EventListViewModel.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch -import kotlinx.coroutines.reactive.asFlow import kotlinx.coroutines.withContext import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.ui.model.ListCardUiModel @@ -82,4 +81,8 @@ class EventListViewModel( _onEventCardClick.emit(eventUidAndOrgUnit) } } + + fun refreshData() { + filterManager.publishData() + } }