fix: add missing home timeline bottom fetcher
This commit is contained in:
parent
e7816f365f
commit
c1e1d527fe
|
@ -100,7 +100,7 @@ extension HomeTimelineViewController {
|
||||||
self.view.backgroundColor = theme.secondarySystemBackgroundColor
|
self.view.backgroundColor = theme.secondarySystemBackgroundColor
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
viewModel.displaySettingBarButtonItem
|
viewModel.$displaySettingBarButtonItem
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak self] displaySettingBarButtonItem in
|
.sink { [weak self] displaySettingBarButtonItem in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
@ -125,7 +125,7 @@ extension HomeTimelineViewController {
|
||||||
settingBarButtonItem.action = #selector(HomeTimelineViewController.settingBarButtonItemPressed(_:))
|
settingBarButtonItem.action = #selector(HomeTimelineViewController.settingBarButtonItemPressed(_:))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
viewModel.displayComposeBarButtonItem
|
viewModel.$displayComposeBarButtonItem
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak self] displayComposeBarButtonItem in
|
.sink { [weak self] displayComposeBarButtonItem in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
@ -190,7 +190,18 @@ extension HomeTimelineViewController {
|
||||||
statusTableViewCellDelegate: self,
|
statusTableViewCellDelegate: self,
|
||||||
timelineMiddleLoaderTableViewCellDelegate: self
|
timelineMiddleLoaderTableViewCellDelegate: 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.loadOldestStateMachine.enter(HomeTimelineViewModel.LoadOldestState.Loading.self)
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
// bind refresh control
|
// bind refresh control
|
||||||
viewModel.didLoadLatest
|
viewModel.didLoadLatest
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
|
@ -282,10 +293,10 @@ extension HomeTimelineViewController {
|
||||||
|
|
||||||
viewModel.viewDidAppear.send()
|
viewModel.viewDidAppear.send()
|
||||||
|
|
||||||
if let timestamp = viewModel.lastAutomaticFetchTimestamp.value {
|
if let timestamp = viewModel.lastAutomaticFetchTimestamp {
|
||||||
let now = Date()
|
let now = Date()
|
||||||
if now.timeIntervalSince(timestamp) > 60 {
|
if now.timeIntervalSince(timestamp) > 60 {
|
||||||
self.viewModel.lastAutomaticFetchTimestamp.value = now
|
self.viewModel.lastAutomaticFetchTimestamp = now
|
||||||
self.viewModel.homeTimelineNeedRefresh.send()
|
self.viewModel.homeTimelineNeedRefresh.send()
|
||||||
} else {
|
} else {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -26,13 +26,14 @@ final class HomeTimelineViewModel: NSObject {
|
||||||
// input
|
// input
|
||||||
let context: AppContext
|
let context: AppContext
|
||||||
let fetchedResultsController: FeedFetchedResultsController
|
let fetchedResultsController: FeedFetchedResultsController
|
||||||
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
|
|
||||||
let viewDidAppear = PassthroughSubject<Void, Never>()
|
|
||||||
let homeTimelineNavigationBarTitleViewModel: HomeTimelineNavigationBarTitleViewModel
|
let homeTimelineNavigationBarTitleViewModel: HomeTimelineNavigationBarTitleViewModel
|
||||||
let lastAutomaticFetchTimestamp = CurrentValueSubject<Date?, Never>(nil)
|
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||||
|
let viewDidAppear = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
|
@Published var lastAutomaticFetchTimestamp: Date? = nil
|
||||||
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
||||||
let displaySettingBarButtonItem = CurrentValueSubject<Bool, Never>(true)
|
@Published var displaySettingBarButtonItem = true
|
||||||
let displayComposeBarButtonItem = CurrentValueSubject<Bool, Never>(true)
|
@Published var displayComposeBarButtonItem = true
|
||||||
|
|
||||||
weak var contentOffsetAdjustableTimelineViewControllerDelegate: ContentOffsetAdjustableTimelineViewControllerDelegate?
|
weak var contentOffsetAdjustableTimelineViewControllerDelegate: ContentOffsetAdjustableTimelineViewControllerDelegate?
|
||||||
weak var tableView: UITableView?
|
weak var tableView: UITableView?
|
||||||
|
|
|
@ -92,13 +92,6 @@ extension UserTimelineViewController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UIScrollViewDelegate
|
|
||||||
//extension UserTimelineViewController {
|
|
||||||
// func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
||||||
// aspectScrollViewDidScroll(scrollView)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - UITableViewDelegate
|
// MARK: - UITableViewDelegate
|
||||||
extension UserTimelineViewController: UITableViewDelegate, AutoGenerateTableViewDelegate {
|
extension UserTimelineViewController: UITableViewDelegate, AutoGenerateTableViewDelegate {
|
||||||
// sourcery:inline:UserTimelineViewController.AutoGenerateTableViewDelegate
|
// sourcery:inline:UserTimelineViewController.AutoGenerateTableViewDelegate
|
||||||
|
@ -126,96 +119,13 @@ extension UserTimelineViewController: UITableViewDelegate, AutoGenerateTableView
|
||||||
}
|
}
|
||||||
|
|
||||||
// sourcery:end
|
// sourcery:end
|
||||||
// func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
||||||
// aspectTableView(tableView, estimatedHeightForRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, willDisplay: cell, forRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, didEndDisplaying: cell, forRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, didSelectRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
|
||||||
// return aspectTableView(tableView, contextMenuConfigurationForRowAt: indexPath, point: point)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
|
||||||
// return aspectTableView(tableView, previewForHighlightingContextMenuWithConfiguration: configuration)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
|
||||||
// return aspectTableView(tableView, previewForDismissingContextMenuWithConfiguration: configuration)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
|
||||||
// aspectTableView(tableView, willPerformPreviewActionForMenuWith: configuration, animator: animator)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// MARK: - UITableViewDataSourcePrefetching
|
|
||||||
//extension UserTimelineViewController: UITableViewDataSourcePrefetching {
|
|
||||||
// func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
|
|
||||||
// aspectTableView(tableView, prefetchRowsAt: indexPaths)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - AVPlayerViewControllerDelegate
|
|
||||||
//extension UserTimelineViewController: AVPlayerViewControllerDelegate {
|
|
||||||
//
|
|
||||||
// func playerViewController(_ playerViewController: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
|
||||||
// aspectPlayerViewController(playerViewController, willBeginFullScreenPresentationWithAnimationCoordinator: coordinator)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
|
||||||
// aspectPlayerViewController(playerViewController, willEndFullScreenPresentationWithAnimationCoordinator: coordinator)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - TimelinePostTableViewCellDelegate
|
|
||||||
//extension UserTimelineViewController: StatusTableViewCellDelegate {
|
|
||||||
// weak var playerViewControllerDelegate: AVPlayerViewControllerDelegate? { return self }
|
|
||||||
// func parent() -> UIViewController { return self }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - CustomScrollViewContainerController
|
// MARK: - CustomScrollViewContainerController
|
||||||
extension UserTimelineViewController: ScrollViewContainer {
|
extension UserTimelineViewController: ScrollViewContainer {
|
||||||
var scrollView: UIScrollView { return tableView }
|
var scrollView: UIScrollView { return tableView }
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - LoadMoreConfigurableTableViewContainer
|
|
||||||
//extension UserTimelineViewController: LoadMoreConfigurableTableViewContainer {
|
|
||||||
// typealias BottomLoaderTableViewCell = TimelineBottomLoaderTableViewCell
|
|
||||||
// typealias LoadingState = UserTimelineViewModel.State.Loading
|
|
||||||
//
|
|
||||||
// var loadMoreConfigurableTableView: UITable``````View { return tableView }
|
|
||||||
// var loadMoreConfigurableStateMachine: GKStateMachine { return viewModel.stateMachine }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//extension UserTimelineViewController {
|
|
||||||
// override var keyCommands: [UIKeyCommand]? {
|
|
||||||
// return navigationKeyCommands + statusNavigationKeyCommands
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//// MARK: - StatusTableViewControllerNavigateable
|
|
||||||
//extension UserTimelineViewController: StatusTableViewControllerNavigateable {
|
|
||||||
// @objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
|
||||||
// navigateKeyCommandHandler(sender)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @objc func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
|
||||||
// statusKeyCommandHandler(sender)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - StatusTableViewCellDelegate
|
// MARK: - StatusTableViewCellDelegate
|
||||||
extension UserTimelineViewController: StatusTableViewCellDelegate { }
|
extension UserTimelineViewController: StatusTableViewCellDelegate { }
|
||||||
|
|
|
@ -38,8 +38,8 @@ final class ContentSplitViewController: UIViewController, NeedsDependency {
|
||||||
private(set) lazy var mainTabBarController: MainTabBarController = {
|
private(set) lazy var mainTabBarController: MainTabBarController = {
|
||||||
let mainTabBarController = MainTabBarController(context: context, coordinator: coordinator)
|
let mainTabBarController = MainTabBarController(context: context, coordinator: coordinator)
|
||||||
if let homeTimelineViewController = mainTabBarController.viewController(of: HomeTimelineViewController.self) {
|
if let homeTimelineViewController = mainTabBarController.viewController(of: HomeTimelineViewController.self) {
|
||||||
homeTimelineViewController.viewModel.displayComposeBarButtonItem.value = false
|
homeTimelineViewController.viewModel.displayComposeBarButtonItem = false
|
||||||
homeTimelineViewController.viewModel.displaySettingBarButtonItem.value = false
|
homeTimelineViewController.viewModel.displaySettingBarButtonItem = false
|
||||||
}
|
}
|
||||||
return mainTabBarController
|
return mainTabBarController
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in New Issue