diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift index 81eb21ae8..4f2c08926 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift @@ -147,18 +147,20 @@ extension HomeTimelineViewModel.LoadLatestState { viewModel.dataController.records = { var oldRecords = viewModel.dataController.records - var newRecords: [MastodonFeed] = newStatuses.map { status in - let hasMore: Bool = { - guard - let firstOldStatus = oldRecords.first?.status - else { - return false - } - /// if the most recent cached item overlaps with the last returned status we know that there - /// is no gap in the timline - return status == newStatuses.last && status != firstOldStatus.entity - }() - return MastodonFeed.fromStatus(.fromEntity(status), kind: .home, hasMore: hasMore) + var newRecords = [MastodonFeed]() + for (index, status) in newStatuses.enumerated() { + if index < newStatuses.count - 1 { + newRecords.append( + MastodonFeed.fromStatus(.fromEntity(status), kind: .home, hasMore: false) + ) + continue + } + + let hasMore = status != oldRecords.first?.status?.entity + + newRecords.append( + MastodonFeed.fromStatus(.fromEntity(status), kind: .home, hasMore: hasMore) + ) } for (i, record) in newRecords.enumerated() { if let index = oldRecords.firstIndex(where: { $0.status?.reblog?.id == record.id || $0.status?.id == record.id }) { diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift index d8c480a28..020960ea5 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift @@ -149,7 +149,6 @@ extension HomeTimelineViewModel { @MainActor func loadMore(item: StatusItem, indexPath: IndexPath) async { guard case let .feedLoader(record) = item else { return } - guard let diffableDataSource = diffableDataSource else { return } guard let status = record.status else { return } record.isLoadingMore = true @@ -158,7 +157,7 @@ extension HomeTimelineViewModel { // fetch data let response = try? await context.apiService.homeTimeline( - maxID: status.id, + sinceID: status.id, authenticationBox: authContext.mastodonAuthenticationBox )