Fix manual refresh of home timeline not working (IOS-176)

This commit is contained in:
Marcus Kida 2023-11-27 11:35:57 +01:00
parent c7d62d56a2
commit 4cb845e0bd
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
1 changed files with 6 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import CoreData
import CoreDataStack
import GameplayKit
import MastodonCore
import MastodonSDK
extension HomeTimelineViewModel {
class LoadLatestState: GKState {
@ -110,6 +111,11 @@ extension HomeTimelineViewModel.LoadLatestState {
if !latestStatusIDs.isEmpty {
viewModel.homeTimelineNavigationBarTitleViewModel.newPostsIncoming()
}
let newRecords: [MastodonFeed] = newStatuses.map {
MastodonFeed.fromStatus(.fromEntity($0), kind: .home)
}
viewModel.fetchedResultsController.records = newRecords + viewModel.fetchedResultsController.records
}
viewModel.timelineIsEmpty.value = latestStatusIDs.isEmpty && statuses.isEmpty