Skip to content

Commit

Permalink
fix: [ANDROAPP-6131] refresh data on resume
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Jun 14, 2024
1 parent 3508924 commit d818054
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class EventListFragment : FragmentGlobalAbstract() {
@Inject
lateinit var cardMapper: EventCardMapper

val eventListViewModel by viewModels<EventListViewModel> { eventListViewModelFactory }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -43,7 +45,6 @@ class EventListFragment : FragmentGlobalAbstract() {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
val workingListViewModel by viewModels<WorkingListViewModel> { workingListViewModelFactory }
val eventListViewModel by viewModels<EventListViewModel> { eventListViewModelFactory }
val programEventsViewModel by activityViewModels<ProgramEventDetailViewModel>()
val cardClicked by eventListViewModel.onEventCardClick.collectAsState(null)
val syncClicked by eventListViewModel.onSyncClick.collectAsState(null)
Expand All @@ -65,4 +66,9 @@ class EventListFragment : FragmentGlobalAbstract() {
}
}
}

override fun onResume() {
super.onResume()
eventListViewModel.refreshData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,4 +81,8 @@ class EventListViewModel(
_onEventCardClick.emit(eventUidAndOrgUnit)
}
}

fun refreshData() {
filterManager.publishData()
}
}

0 comments on commit d818054

Please sign in to comment.