feat(creator): 커뮤니티 좋아요를 연결한다
This commit is contained in:
@@ -160,7 +160,8 @@ struct CreatorChannelView: View {
|
|||||||
onTapContent: showContentDetail,
|
onTapContent: showContentDetail,
|
||||||
onTapDonate: showDonationDialog,
|
onTapDonate: showDonationDialog,
|
||||||
onTapSchedule: handleScheduleTap,
|
onTapSchedule: handleScheduleTap,
|
||||||
onTapSeries: showSeriesDetail
|
onTapSeries: showSeriesDetail,
|
||||||
|
onTapCommunityLike: viewModel.likeCommunityPost
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Combine
|
|||||||
final class CreatorChannelViewModel: ObservableObject {
|
final class CreatorChannelViewModel: ObservableObject {
|
||||||
private let repository = CreatorChannelHomeRepository()
|
private let repository = CreatorChannelHomeRepository()
|
||||||
private let userRepository = UserRepository()
|
private let userRepository = UserRepository()
|
||||||
|
private let communityRepository = CreatorCommunityRepository()
|
||||||
private var subscription = Set<AnyCancellable>()
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
@Published var isLoading = false
|
@Published var isLoading = false
|
||||||
@@ -101,6 +102,25 @@ final class CreatorChannelViewModel: ObservableObject {
|
|||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func likeCommunityPost(postId: Int) {
|
||||||
|
guard postId > 0 else { return }
|
||||||
|
|
||||||
|
communityRepository.communityPostLike(postId: postId)
|
||||||
|
.sink { [weak self] result in
|
||||||
|
guard let self else { return }
|
||||||
|
|
||||||
|
switch result {
|
||||||
|
case .finished:
|
||||||
|
DEBUG_LOG("finish")
|
||||||
|
case .failure(let error):
|
||||||
|
ERROR_LOG(error.localizedDescription)
|
||||||
|
self.errorMessage = I18n.Common.commonError
|
||||||
|
self.isShowPopup = true
|
||||||
|
}
|
||||||
|
} receiveValue: { _ in }
|
||||||
|
.store(in: &subscription)
|
||||||
|
}
|
||||||
|
|
||||||
private func applyApiFailedPlaceholderState() {
|
private func applyApiFailedPlaceholderState() {
|
||||||
response = nil
|
response = nil
|
||||||
isApiFailedPlaceholderVisible = true
|
isApiFailedPlaceholderVisible = true
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ struct CreatorChannelHomeView: View {
|
|||||||
let onTapDonate: () -> Void
|
let onTapDonate: () -> Void
|
||||||
let onTapSchedule: (CreatorActivityType, Int) -> Void
|
let onTapSchedule: (CreatorActivityType, Int) -> Void
|
||||||
let onTapSeries: (Int) -> Void
|
let onTapSeries: (Int) -> Void
|
||||||
|
let onTapCommunityLike: (Int) -> Void
|
||||||
|
|
||||||
init(
|
init(
|
||||||
response: CreatorChannelHomeResponse,
|
response: CreatorChannelHomeResponse,
|
||||||
@@ -16,7 +17,8 @@ struct CreatorChannelHomeView: View {
|
|||||||
onTapContent: @escaping (Int) -> Void = { _ in },
|
onTapContent: @escaping (Int) -> Void = { _ in },
|
||||||
onTapDonate: @escaping () -> Void = {},
|
onTapDonate: @escaping () -> Void = {},
|
||||||
onTapSchedule: @escaping (CreatorActivityType, Int) -> Void = { _, _ in },
|
onTapSchedule: @escaping (CreatorActivityType, Int) -> Void = { _, _ in },
|
||||||
onTapSeries: @escaping (Int) -> Void = { _ in }
|
onTapSeries: @escaping (Int) -> Void = { _ in },
|
||||||
|
onTapCommunityLike: @escaping (Int) -> Void = { _ in }
|
||||||
) {
|
) {
|
||||||
self.response = response
|
self.response = response
|
||||||
self.onSelectTab = onSelectTab
|
self.onSelectTab = onSelectTab
|
||||||
@@ -25,6 +27,7 @@ struct CreatorChannelHomeView: View {
|
|||||||
self.onTapDonate = onTapDonate
|
self.onTapDonate = onTapDonate
|
||||||
self.onTapSchedule = onTapSchedule
|
self.onTapSchedule = onTapSchedule
|
||||||
self.onTapSeries = onTapSeries
|
self.onTapSeries = onTapSeries
|
||||||
|
self.onTapCommunityLike = onTapCommunityLike
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -66,7 +69,8 @@ struct CreatorChannelHomeView: View {
|
|||||||
|
|
||||||
CreatorChannelCommunitySection(
|
CreatorChannelCommunitySection(
|
||||||
communities: response.communities,
|
communities: response.communities,
|
||||||
onSelectTab: onSelectTab
|
onSelectTab: onSelectTab,
|
||||||
|
onTapLike: onTapCommunityLike
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|||||||
Reference in New Issue
Block a user