From 622a2fa5c936ff4717855fd58dcaccd0e9578912 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Fri, 24 May 2024 15:46:08 +0200 Subject: [PATCH] Load more entries from user timeline (IOS-272) --- .../Timeline/UserTimelineViewController.swift | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift index 71261ca52..49c3bc2ec 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift @@ -54,17 +54,6 @@ extension UserTimelineViewController { tableView: tableView, statusTableViewCellDelegate: self ) - - // 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(UserTimelineViewModel.State.Loading.self) - } - .store(in: &disposeBag) } override func viewWillAppear(_ animated: Bool) { @@ -169,3 +158,12 @@ extension UserTimelineViewController: IndicatorInfoProvider { return IndicatorInfo(title: viewModel.title) } } + +//MARK: - UIScrollViewDelegate +extension UserTimelineViewController: UIScrollViewDelegate { + func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + ListBatchFetchViewModel.scrollViewDidScrollToEnd(scrollView) { + viewModel.stateMachine.enter(UserTimelineViewModel.State.Loading.self) + } + } +}