feat(content): 랭킹 유형 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-07 00:38:48 +09:00
parent 9c4c304fc6
commit b33aed94c6
6 changed files with 138 additions and 13 deletions

View File

@@ -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()
}
}