feat(creator): 커뮤니티 좋아요를 연결한다
This commit is contained in:
@@ -160,7 +160,8 @@ struct CreatorChannelView: View {
|
||||
onTapContent: showContentDetail,
|
||||
onTapDonate: showDonationDialog,
|
||||
onTapSchedule: handleScheduleTap,
|
||||
onTapSeries: showSeriesDetail
|
||||
onTapSeries: showSeriesDetail,
|
||||
onTapCommunityLike: viewModel.likeCommunityPost
|
||||
)
|
||||
} else {
|
||||
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
||||
|
||||
@@ -4,6 +4,7 @@ import Combine
|
||||
final class CreatorChannelViewModel: ObservableObject {
|
||||
private let repository = CreatorChannelHomeRepository()
|
||||
private let userRepository = UserRepository()
|
||||
private let communityRepository = CreatorCommunityRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
@Published var isLoading = false
|
||||
@@ -101,6 +102,25 @@ final class CreatorChannelViewModel: ObservableObject {
|
||||
.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() {
|
||||
response = nil
|
||||
isApiFailedPlaceholderVisible = true
|
||||
|
||||
@@ -8,6 +8,7 @@ struct CreatorChannelHomeView: View {
|
||||
let onTapDonate: () -> Void
|
||||
let onTapSchedule: (CreatorActivityType, Int) -> Void
|
||||
let onTapSeries: (Int) -> Void
|
||||
let onTapCommunityLike: (Int) -> Void
|
||||
|
||||
init(
|
||||
response: CreatorChannelHomeResponse,
|
||||
@@ -16,7 +17,8 @@ struct CreatorChannelHomeView: View {
|
||||
onTapContent: @escaping (Int) -> Void = { _ in },
|
||||
onTapDonate: @escaping () -> Void = {},
|
||||
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.onSelectTab = onSelectTab
|
||||
@@ -25,6 +27,7 @@ struct CreatorChannelHomeView: View {
|
||||
self.onTapDonate = onTapDonate
|
||||
self.onTapSchedule = onTapSchedule
|
||||
self.onTapSeries = onTapSeries
|
||||
self.onTapCommunityLike = onTapCommunityLike
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -66,7 +69,8 @@ struct CreatorChannelHomeView: View {
|
||||
|
||||
CreatorChannelCommunitySection(
|
||||
communities: response.communities,
|
||||
onSelectTab: onSelectTab
|
||||
onSelectTab: onSelectTab,
|
||||
onTapLike: onTapCommunityLike
|
||||
)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Reference in New Issue
Block a user