load more posts to report immediately (IOS-272)

This commit is contained in:
Nathan Mattes 2024-05-24 15:30:26 +02:00
parent bd9d19f8b6
commit ec6312b225
1 changed files with 11 additions and 12 deletions

View File

@ -96,17 +96,6 @@ extension ReportStatusViewController {
} }
.store(in: &observations) .store(in: &observations)
// setup batch fetch
viewModel.listBatchFetchViewModel.setup(scrollView: tableView)
viewModel.listBatchFetchViewModel.shouldFetch
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
guard let self = self else { return }
guard self.view.window != nil else { return }
self.viewModel.stateMachine.enter(ReportStatusViewModel.State.Loading.self)
}
.store(in: &disposeBag)
viewModel.$isNextButtonEnabled viewModel.$isNextButtonEnabled
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.assign(to: \.isEnabled, on: navigationActionView.nextButton) .assign(to: \.isEnabled, on: navigationActionView.nextButton)
@ -119,7 +108,7 @@ extension ReportStatusViewController {
navigationActionView.backButton.addTarget(self, action: #selector(ReportStatusViewController.skipButtonDidPressed(_:)), for: .touchUpInside) navigationActionView.backButton.addTarget(self, action: #selector(ReportStatusViewController.skipButtonDidPressed(_:)), for: .touchUpInside)
navigationActionView.nextButton.addTarget(self, action: #selector(ReportStatusViewController.nextButtonDidPressed(_:)), for: .touchUpInside) navigationActionView.nextButton.addTarget(self, action: #selector(ReportStatusViewController.nextButtonDidPressed(_:)), for: .touchUpInside)
viewModel.listBatchFetchViewModel.shouldFetch.send() viewModel.stateMachine.enter(ReportStatusViewModel.State.Loading.self)
} }
} }
@ -197,3 +186,13 @@ extension ReportStatusViewController: UIAdaptivePresentationControllerDelegate {
return false return false
} }
} }
//MARK: - UIScrollViewDelegate
extension ReportStatusViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
ListBatchFetchViewModel.scrollViewdidScrollToEnd(scrollView) {
viewModel.stateMachine.enter(ReportStatusViewModel.State.Loading.self)
}
}
}