Skip to content

Commit

Permalink
refactor(Bookmark): ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
re4rk committed May 1, 2024
1 parent 1f67765 commit 5da4597
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.festago.festago.data.repository.DefaultRecentSearchRepository
import com.festago.festago.data.repository.DefaultSchoolRepository
import com.festago.festago.data.repository.DefaultSearchRepository
import com.festago.festago.data.repository.DefaultUserRepository
import com.festago.festago.data.repository.FakeBookmarkRepository
import com.festago.festago.domain.repository.ArtistRepository
import com.festago.festago.domain.repository.BookmarkRepository
import com.festago.festago.domain.repository.FestivalRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,24 @@ class FestivalDetailViewModel @Inject constructor(
value = it.message.toString(),
)
}


}
}

private fun FestivalDetail.toSuccessUiState() =
FestivalDetailUiState.Success(
festival = FestivalUiState(
id = id,
name = name,
startDate = startDate,
endDate = endDate,
posterImageUrl = posterImageUrl,
school = school,
onSchoolClick = ::showSchoolDetail,
socialMedias = socialMedias,
),
bookmarked = false,
stages = stages.map { it.toUiState() },
onBookmarkClick = { festivalId -> toggleFestivalBookmark(festivalId) },
)
private fun FestivalDetail.toSuccessUiState() = FestivalDetailUiState.Success(
festival = FestivalUiState(
id = id,
name = name,
startDate = startDate,
endDate = endDate,
posterImageUrl = posterImageUrl,
school = school,
onSchoolClick = ::showSchoolDetail,
socialMedias = socialMedias,
),
bookmarked = false,
stages = stages.map { it.toUiState() },
onBookmarkClick = { festivalId -> toggleFestivalBookmark(festivalId) },
)

private fun toggleFestivalBookmark(festivalId: Long) {
viewModelScope.launch {
Expand All @@ -90,12 +87,10 @@ class FestivalDetailViewModel @Inject constructor(
bookmarkRepository.deleteFestivalBookmark(festivalId)
.onSuccess { _uiState.value = uiState.copy(bookmarked = false) }
.onFailure { _event.emit(FailedToFetchBookmarkList("์ตœ๋Œ€ ๋ถ๋งˆํฌ ๊ฐฏ์ˆ˜๋ฅผ ์ดˆ๊ณผํ–ˆ์Šต๋‹ˆ๋‹ค")) }

} else {
bookmarkRepository.addFestivalBookmark(festivalId)
.onSuccess { _uiState.value = uiState.copy(bookmarked = true) }
.onFailure { _event.emit(FailedToFetchBookmarkList("์ตœ๋Œ€ ๋ถ๋งˆํฌ ๊ฐฏ์ˆ˜๋ฅผ ์ดˆ๊ณผํ–ˆ์Šต๋‹ˆ๋‹ค")) }

}
}
}
Expand Down

0 comments on commit 5da4597

Please sign in to comment.