From 2387d255988af2526a4b8d6a10ca270c5c3abc30 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Fri, 3 May 2024 14:43:00 +0200 Subject: [PATCH] Implement subsequent "Load More" (IOS-266) --- .../HomeTimeline/HomeTimelineViewModel.swift | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift index f60935f63..b629c2771 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift @@ -173,22 +173,40 @@ extension HomeTimelineViewModel { } // insert missing items - if let items = response?.value { - let feedItems: [MastodonFeed] = items.map { .fromStatus($0.asMastodonStatus, kind: .home, hasMore: false) } - - let firstIndex = indexPath.row - let count = dataController.records.count - let head = dataController.records[.. we got another gap + hasMore = item != head.first?.status?.entity + } + + feedItems.append( + .fromStatus(item.asMastodonStatus, kind: .home, hasMore: hasMore) + ) + } + + let combinedRecords = Array(head + feedItems + tail) + dataController.records = combinedRecords + + record.isLoadingMore = false + record.hasMore = false } }