diff --git a/SodaLive/Sources/Explorer/Profile/CreatorCommunity/All/CreatorCommunityAllViewModel.swift b/SodaLive/Sources/Explorer/Profile/CreatorCommunity/All/CreatorCommunityAllViewModel.swift index 9282819..124a64e 100644 --- a/SodaLive/Sources/Explorer/Profile/CreatorCommunity/All/CreatorCommunityAllViewModel.swift +++ b/SodaLive/Sources/Explorer/Profile/CreatorCommunity/All/CreatorCommunityAllViewModel.swift @@ -119,49 +119,47 @@ class CreatorCommunityAllViewModel: ObservableObject { } func createCommunityPostComment(comment: String, postId: Int, parentId: Int? = nil) { - if !isLoading && !isLast { - isLoading = true - - repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId) - .sink { result in - switch result { - case .finished: - DEBUG_LOG("finish") - case .failure(let error): - ERROR_LOG(error.localizedDescription) - } - } receiveValue: { [unowned self] response in - let responseData = response.data + isLoading = true + + repository.createCommunityPostComment(comment: comment, postId: postId, parentId: parentId) + .sink { result in + switch result { + case .finished: + DEBUG_LOG("finish") + case .failure(let error): + ERROR_LOG(error.localizedDescription) + } + } receiveValue: { [unowned self] response in + let responseData = response.data + + do { + let jsonDecoder = JSONDecoder() + let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) - do { - let jsonDecoder = JSONDecoder() - let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) - - if decoded.success { - DispatchQueue.main.async { - self.pageSize *= self.page - self.page = 1 - self.isLast = false - self.getCommunityPostList() - } - } else { - if let message = decoded.message { - self.errorMessage = message - } else { - self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." - } - - self.isShowPopup = true + if decoded.success { + DispatchQueue.main.async { + self.pageSize *= self.page + self.page = 1 + self.isLast = false + self.getCommunityPostList() } - } catch { - self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + } else { + if let message = decoded.message { + self.errorMessage = message + } else { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + } + self.isShowPopup = true } - - self.isLoading = false + } catch { + self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다." + self.isShowPopup = true } - .store(in: &subscription) - } + + self.isLoading = false + } + .store(in: &subscription) } func report(reason: String) {