diff --git a/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewControllers/HomeViewController.swift b/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewControllers/HomeViewController.swift index cc567b21..8a72e672 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewControllers/HomeViewController.swift @@ -91,8 +91,6 @@ final class HomeViewController: UIViewController { } override func viewWillDisappear(_ animated: Bool) { - refreshCollectionViewDidDrag() - self.navigationController?.navigationBar.isHidden = false self.navigationController?.navigationBar.backgroundColor = .clear @@ -154,7 +152,6 @@ extension HomeViewController { deletePostBottomsheetView.dimView.removeFromSuperview() deletePostBottomsheetView.bottomsheetView.removeFromSuperview() } - refreshCollectionViewDidDrag() } func showDeletePostPopupView() { @@ -179,7 +176,6 @@ extension HomeViewController { warnUserBottomsheetView.dimView.removeFromSuperview() warnUserBottomsheetView.bottomsheetView.removeFromSuperview() } - refreshCollectionViewDidDrag() } func showWarnUserSafariView() { diff --git a/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewModel/HomeViewModel.swift b/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewModel/HomeViewModel.swift index 81530790..3e34f481 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewModel/HomeViewModel.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/Home/ViewModel/HomeViewModel.swift @@ -176,11 +176,15 @@ extension HomeViewModel { } else { var tempArrayData: [PostDataResponseDTO] = [] - for content in data { - tempArrayData.append(content) + if data.isEmpty { + self.cursor = -1 + } else { + for content in data { + tempArrayData.append(content) + } + self.postData = tempArrayData + postDatas.append(contentsOf: postData) } - self.postData = tempArrayData - postDatas.append(contentsOf: postData) } } return result diff --git a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageContentViewController.swift b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageContentViewController.swift index 24720084..54d4ab03 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageContentViewController.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageContentViewController.swift @@ -240,11 +240,6 @@ extension MyPageContentViewController: UICollectionViewDelegate { } extension MyPageContentViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - if self.contentDatas.count == 0 { - firstContentButton.isHidden = false - } else { - firstContentButton.isHidden = true - } return self.contentDatas.count } diff --git a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift index fd51d262..409785e1 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewControllers/MyPageViewController.swift @@ -31,6 +31,7 @@ final class MyPageViewController: UIViewController { private lazy var sixthReason = self.transparentReasonView.sixthReasonView.radioButton.publisher(for: .touchUpInside).map { _ in }.eraseToAnyPublisher() var memberId: Int = loadUserData()?.memberId ?? 0 + var memberProfileImage: String = loadUserData()?.userProfileImage ?? "" var contentId: Int = 0 var alarmTriggerType: String = "" var targetMemberId: Int = 0 @@ -122,8 +123,10 @@ final class MyPageViewController: UIViewController { bindHomeViewModel() setNotification() - DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { - self.refreshData() + if loadUserData()?.userProfileImage != self.memberProfileImage { + DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { + self.refreshData() + } } let image = ImageLiterals.MyPage.icnMenu @@ -254,6 +257,8 @@ extension MyPageViewController { @objc func refreshData() { DispatchQueue.main.async { + self.contentCursor = -1 + self.commentCursor = -1 self.bindViewModel() } self.perform(#selector(self.finishedRefreshing), with: nil, afterDelay: 0.1) @@ -355,11 +360,23 @@ extension MyPageViewController { .receive(on: RunLoop.main) .sink { data in self.rootView.myPageContentViewController.contentDatas = data + self.viewModel.contentCursor = self.contentCursor + if data.isEmpty { + self.viewModel.contentCursor = -1 + } else { + self.viewModel.contentCursor = self.contentCursor + } if !data.isEmpty { self.rootView.myPageContentViewController.noContentLabel.isHidden = true self.rootView.myPageContentViewController.firstContentButton.isHidden = true } else { - self.rootView.myPageContentViewController.noContentLabel.isHidden = false + if loadUserData()?.memberId != self.memberId { + self.rootView.myPageContentViewController.noContentLabel.isHidden = false + self.rootView.myPageContentViewController.firstContentButton.isHidden = true + } else { + self.rootView.myPageContentViewController.noContentLabel.isHidden = false + self.rootView.myPageContentViewController.firstContentButton.isHidden = false + } } DispatchQueue.main.async { self.rootView.myPageContentViewController.homeCollectionView.reloadData() @@ -468,7 +485,6 @@ extension MyPageViewController { if data.memberId != loadUserData()?.memberId ?? 0 { self.rootView.myPageContentViewController.noContentLabel.text = "아직 \(data.nickname)" + StringLiterals.MyPage.myPageNoContentOtherLabel self.rootView.myPageCommentViewController.noCommentLabel.text = "아직 \(data.nickname)" + StringLiterals.MyPage.myPageNoCommentOtherLabel - self.rootView.myPageContentViewController.firstContentButton.isHidden = true } else { self.rootView.myPageContentViewController.noContentLabel.text = "\(data.nickname)" + StringLiterals.MyPage.myPageNoContentLabel self.rootView.myPageCommentViewController.noCommentLabel.text = StringLiterals.MyPage.myPageNoCommentLabel diff --git a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewModels/MyPageViewModel.swift b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewModels/MyPageViewModel.swift index 02e9c03e..71a4b468 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewModels/MyPageViewModel.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/MyPage/ViewModels/MyPageViewModel.swift @@ -144,11 +144,15 @@ extension MyPageViewModel { } else { var tempArrayData: [MyPageMemberContentResponseDTO] = [] - for content in data { - tempArrayData.append(content) + if data.isEmpty { + self.contentCursor = -1 + } else { + for content in data { + tempArrayData.append(content) + } + self.myPageContentData = tempArrayData + myPageContentDatas.append(contentsOf: myPageContentData) } - self.myPageContentData = tempArrayData - myPageContentDatas.append(contentsOf: myPageContentData) } } return result diff --git a/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewControllers/PostDetailViewController.swift b/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewControllers/PostDetailViewController.swift index 1dc204fb..9d61f2d6 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewControllers/PostDetailViewController.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewControllers/PostDetailViewController.swift @@ -82,8 +82,6 @@ final class PostDetailViewController: UIViewController { setTextFieldGesture() setRefreshControll() setLayout() - refreshPostDidDrag() - refreshControl.beginRefreshing() } init(viewModel: PostDetailViewModel) { diff --git a/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewModel/PostDetailViewModel.swift b/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewModel/PostDetailViewModel.swift index 14b5b6b3..120de085 100644 --- a/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewModel/PostDetailViewModel.swift +++ b/DontBe-iOS/DontBe-iOS/Presentation/Post/ViewModel/PostDetailViewModel.swift @@ -110,17 +110,23 @@ final class PostDetailViewModel: ViewModelType { let postReplyResult = try await self.getPostReplyDataAPI(accessToken: accessToken, contentId: value) if let data = postReplyResult?.data { + if let lastCommentId = data.last?.commentId { + self.cursor = lastCommentId + } if self.cursor == -1 { self.postReplyDatas = [] self.postReplyData = data self.getPostReplyData.send(data) + + postReplyDatas.append(contentsOf: postReplyData) } else { self.postReplyData = data self.getPostReplyData.send(data) + + postReplyDatas.append(contentsOf: postReplyData) } } - postReplyDatas.append(contentsOf: postReplyData) } } catch { print(error)