Fix timeline momentum scrolling stopping due to adding footer section
This commit is contained in:
parent
5f9fe505d5
commit
dc1ea1bed9
|
@ -107,8 +107,8 @@ class TimelineTableViewController: DiffableTimelineLikeTableViewController<Timel
|
||||||
|
|
||||||
self.mastodonController.persistentContainer.addAll(statuses: statuses) {
|
self.mastodonController.persistentContainer.addAll(statuses: statuses) {
|
||||||
var snapshot = Snapshot()
|
var snapshot = Snapshot()
|
||||||
snapshot.appendSections([.statuses])
|
snapshot.appendSections([.statuses, .footer])
|
||||||
snapshot.appendItems(statuses.map { .status(id: $0.id, state: .unknown) })
|
snapshot.appendItems(statuses.map { .status(id: $0.id, state: .unknown) }, toSection: .statuses)
|
||||||
completion(.success(snapshot))
|
completion(.success(snapshot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,13 +122,12 @@ class TimelineTableViewController: DiffableTimelineLikeTableViewController<Timel
|
||||||
}
|
}
|
||||||
|
|
||||||
guard !Preferences.shared.disableInfiniteScrolling || didConfirmLoadMore else {
|
guard !Preferences.shared.disableInfiniteScrolling || didConfirmLoadMore else {
|
||||||
guard !currentSnapshot.sectionIdentifiers.contains(.footer) || !currentSnapshot.itemIdentifiers(inSection: .footer).contains(.confirmLoadMore) else {
|
guard !currentSnapshot.itemIdentifiers(inSection: .footer).contains(.confirmLoadMore) else {
|
||||||
// todo: need something more accurate than "success"/"failure"
|
// todo: need something more accurate than "success"/"failure"
|
||||||
completion(.success(currentSnapshot))
|
completion(.success(currentSnapshot))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var snapshot = currentSnapshot
|
var snapshot = currentSnapshot
|
||||||
snapshot.appendSections([.footer])
|
|
||||||
snapshot.appendItems([.confirmLoadMore], toSection: .footer)
|
snapshot.appendItems([.confirmLoadMore], toSection: .footer)
|
||||||
self.dataSource.apply(snapshot)
|
self.dataSource.apply(snapshot)
|
||||||
completion(.success(snapshot))
|
completion(.success(snapshot))
|
||||||
|
@ -148,7 +147,7 @@ class TimelineTableViewController: DiffableTimelineLikeTableViewController<Timel
|
||||||
self.mastodonController.persistentContainer.addAll(statuses: statuses) {
|
self.mastodonController.persistentContainer.addAll(statuses: statuses) {
|
||||||
var snapshot = currentSnapshot
|
var snapshot = currentSnapshot
|
||||||
snapshot.appendItems(statuses.map { .status(id: $0.id, state: .unknown) }, toSection: .statuses)
|
snapshot.appendItems(statuses.map { .status(id: $0.id, state: .unknown) }, toSection: .statuses)
|
||||||
snapshot.deleteSections([.footer])
|
snapshot.deleteItems([.confirmLoadMore])
|
||||||
completion(.success(snapshot))
|
completion(.success(snapshot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,8 @@ class DiffableTimelineLikeTableViewController<Section: Hashable & CaseIterable,
|
||||||
// this assumes that indexPathsForVisibleRows is always in order
|
// this assumes that indexPathsForVisibleRows is always in order
|
||||||
lastLastVisibleRow = tableView.indexPathsForVisibleRows?.last
|
lastLastVisibleRow = tableView.indexPathsForVisibleRows?.last
|
||||||
|
|
||||||
if indexPath.section == tableView.numberOfSections - 1,
|
let orderedContentSections = dataSource.snapshot().sectionIdentifiers.filter { timelineContentSections().contains($0) }
|
||||||
|
if indexPath.section == orderedContentSections.count - 1,
|
||||||
indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 {
|
indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 {
|
||||||
|
|
||||||
loadOlder()
|
loadOlder()
|
||||||
|
|
Loading…
Reference in New Issue