feat(content): 랭킹 유형 탭을 추가한다
This commit is contained in:
@@ -11,6 +11,7 @@ final class MainContentRankingViewModel: ObservableObject {
|
||||
@Published var items = [AudioRankingItemResponse]()
|
||||
@Published var showRankChange = false
|
||||
@Published var hasLoaded = false
|
||||
@Published var selectedType: AudioRankingType = .weeklyPopular
|
||||
|
||||
var emptyStateMessage: String {
|
||||
if !errorMessage.isEmpty {
|
||||
@@ -29,7 +30,7 @@ final class MainContentRankingViewModel: ObservableObject {
|
||||
|
||||
isLoading = true
|
||||
|
||||
repository.getAudioRankings()
|
||||
repository.getAudioRankings(type: selectedType)
|
||||
.sink { [weak self] result in
|
||||
guard let self else { return }
|
||||
|
||||
@@ -77,4 +78,16 @@ final class MainContentRankingViewModel: ObservableObject {
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func selectType(_ type: AudioRankingType) {
|
||||
guard selectedType != type else { return }
|
||||
|
||||
subscription.forEach { $0.cancel() }
|
||||
subscription.removeAll()
|
||||
selectedType = type
|
||||
items = []
|
||||
isLoading = false
|
||||
hasLoaded = false
|
||||
fetchRankings()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user