Load more discovery news right away (IOS-272)

This commit is contained in:
Nathan Mattes 2024-05-23 15:52:30 +02:00
parent 6b99c9def3
commit a86fc70828
1 changed files with 10 additions and 11 deletions

View File

@ -57,17 +57,6 @@ extension DiscoveryNewsViewController {
self.refreshControl.endRefreshing()
}
.store(in: &disposeBag)
// 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(DiscoveryNewsViewModel.State.Loading.self)
}
.store(in: &disposeBag)
}
override func viewWillAppear(_ animated: Bool) {
@ -205,3 +194,13 @@ extension DiscoveryNewsViewController: TableViewControllerNavigateable {
}
}
//MARK: - UIScrollViewDelegate
extension DiscoveryNewsViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
ListBatchFetchViewModel.scrollViewdidScrollToEnd(scrollView) {
viewModel.stateMachine.enter(DiscoveryNewsViewModel.State.Loading.self)
}
}
}