Skip to content

Commit

Permalink
fix: 새로고침시 지역 필터링 유지
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyCh0 committed Mar 30, 2024
1 parent 382830f commit 20d8319
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ class FestivalListViewModel @Inject constructor(

fun initFestivalList() {
viewModelScope.launch {
val schoolRegion = (uiState.value as? FestivalListUiState.Success)?.schoolRegion
val deferredPopularFestivals = async { festivalRepository.loadPopularFestivals() }
val deferredFestivals = async {
festivalRepository.loadFestivals(festivalFilter = festivalFilter)
festivalRepository.loadFestivals(
schoolRegion = schoolRegion,
festivalFilter = festivalFilter
)
}
runCatching {
val festivalsPage = deferredFestivals.await().getOrThrow()
Expand All @@ -57,6 +61,7 @@ class FestivalListViewModel @Inject constructor(
festivals = festivalsPage.festivals.map { it.toUiState() },
festivalFilter = festivalFilter.toUiState(),
isLastPage = festivalsPage.isLastPage,
schoolRegion = schoolRegion,
)
}.onFailure {
_uiState.value = FestivalListUiState.Error
Expand Down

0 comments on commit 20d8319

Please sign in to comment.