Skip to content

Commit

Permalink
✅ Chore: CommunityMain 성능 개선을 위한 자잘한 코드 수정 (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangJi-dev committed Nov 2, 2022
1 parent 26c04ee commit 5aab81a
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ extension CommunityMainVC {
private func bindState(_ reactor: CommunityMainReactor) {
reactor.state
.map { $0.communityList }
.distinctUntilChanged()
.bind(to: communityTV.rx.items) { tableView, index, item in

let indexPath = IndexPath(row: index, section: 0)
Expand Down Expand Up @@ -175,13 +176,15 @@ extension CommunityMainVC {
.subscribe(onNext: { [weak self] loading in
DispatchQueue.main.async {
self?.view.bringSubviewToFront(self?.activityIndicator ?? UIView())

if loading {
self?.activityIndicator.startAnimating()
self?.setEmptyLabelIsHidden(isHidden: true)
} else {
self?.activityIndicator.stopAnimating()
if reactor.currentState.animateToTopState {
self?.communitySV.contentOffset.y = 0
reactor.action.onNext(.changeAnimateState)
}
self?.setEmptyLabelIsHidden(isHidden: reactor.currentState.communityList.isEmpty ? false : true)
}
Expand Down Expand Up @@ -305,7 +308,7 @@ extension CommunityMainVC {
$0.top.equalToSuperview()
$0.leading.equalToSuperview().offset(16)
$0.trailing.bottom.equalToSuperview().offset(-16)
$0.height.equalTo(0)
$0.height.equalTo(UIScreen.main.bounds.height)
}
}

Expand Down Expand Up @@ -352,8 +355,8 @@ extension CommunityMainVC {
self.present(slideVC, animated: true)
}

private func sendFilterFilledAction(majorName: String, majorID: Int) {
self.reactor?.action.onNext(.filterFilled(fill: majorName == "" ? false : true, majorID: majorID, type: PostFilterType(rawValue: 0) ?? .community))
private func sendFilterFilledAction(majorName: String, majorID: Int, selectedIndex: Int) {
self.reactor?.action.onNext(.filterFilled(fill: majorName == "" ? false : true, majorID: majorID, type: PostFilterType(rawValue: selectedIndex) ?? .community))
}
}

Expand Down Expand Up @@ -392,9 +395,10 @@ extension CommunityMainVC: SendPostTypeDelegate {
// MARK: - SendCommunityInfoDelegate
extension CommunityMainVC: SendCommunityInfoDelegate {
func sendCommunityInfo(majorID: Int, majorName: String) {
self.activityIndicator.startAnimating()
let selectedIndex = communitySegmentedControl.selectedSegmentIndex
DispatchQueue.global().async {
self.sendFilterFilledAction(majorName: majorName, majorID: majorID)
self.sendFilterFilledAction(majorName: majorName, majorID: majorID, selectedIndex: selectedIndex)
}
}

}

0 comments on commit 5aab81a

Please sign in to comment.