Fix potential excessive Load More at end of timeline (IOS-275)
This commit is contained in:
parent
a23b5089d0
commit
d61b10a8e6
|
@ -147,10 +147,15 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
|
||||
let last = statuses.last
|
||||
if let latestFirstId = latestFeedRecords.first?.id, let last, last.id == latestFirstId {
|
||||
/// We have an overlap with the existing Statuses, thus no _Load More_ required
|
||||
toAdd = statuses.prefix(statuses.count-1).map({ MastodonFeed.fromStatus($0.asMastodonStatus, kind: .home) })
|
||||
} else {
|
||||
} else if latestFeedRecords.isNotEmpty {
|
||||
/// Our fetched Statuses do **not** overlap with the existing ones, we need a _Load More_ Button
|
||||
toAdd = statuses.map({ MastodonFeed.fromStatus($0.asMastodonStatus, kind: .home) })
|
||||
toAdd.last?.hasMore = true
|
||||
} else {
|
||||
/// We do not have existing items, no load more is required as there can't be a gap
|
||||
toAdd = statuses.map({ MastodonFeed.fromStatus($0.asMastodonStatus, kind: .home) })
|
||||
}
|
||||
|
||||
viewModel.dataController.records = (toAdd + latestFeedRecords).removingDuplicates()
|
||||
|
|
Loading…
Reference in New Issue