feat(content): 추천 전체보기를 연결한다

This commit is contained in:
Yu Sung
2026-07-07 11:54:31 +09:00
parent b33aed94c6
commit 981c02a8e1
18 changed files with 1169 additions and 294 deletions

View File

@@ -23,7 +23,7 @@ final class MainContentAllViewModel: ObservableObject {
@Published var isShowPopup = false
var allowedSorts: [ContentSort] {
selectedType == .free ? [.latest, .popular] : ContentSort.allCases
allowedSorts(for: selectedType)
}
var shouldShowEmptyState: Bool {
@@ -40,6 +40,19 @@ final class MainContentAllViewModel: ObservableObject {
fetchContents(page: 0, isNextPage: false)
}
func apply(type: MainContentAllType, sort: ContentSort) {
guard allowedSorts(for: type).contains(sort) else { return }
if selectedType == type, selectedSort == sort, hasLoaded {
return
}
selectedType = type
selectedSort = sort
clearItems()
fetchFirstPage()
}
func selectType(_ type: MainContentAllType) {
guard selectedType != type else { return }
@@ -77,6 +90,10 @@ final class MainContentAllViewModel: ObservableObject {
fetchNextPageIfPossible()
}
private func allowedSorts(for type: MainContentAllType) -> [ContentSort] {
type == .free ? [.latest, .popular] : ContentSort.allCases
}
private func fetchNextPageIfPossible() {
guard hasNext, isLoading == false, isLoadingNextPage == false else { return }
fetchContents(page: page + 1, isNextPage: true)