Implement sinceID usage when loading latest posts (IOS-266)
This commit is contained in:
parent
9714a37386
commit
efcb91fff1
|
@ -116,15 +116,20 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
do {
|
||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
||||
let response: Mastodon.Response.Content<[Mastodon.Entity.Status]>
|
||||
|
||||
|
||||
/// To find out wether or not we need to show the "Load More" button
|
||||
/// we have make sure to eventually overlap with the most recent cached item
|
||||
let sinceID = latestFeedRecords.count > 1 ? latestFeedRecords[1].id : "1"
|
||||
|
||||
switch viewModel.timelineContext {
|
||||
case .home:
|
||||
response = try await viewModel.context.apiService.homeTimeline(
|
||||
sinceID: sinceID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case .public:
|
||||
response = try await viewModel.context.apiService.publicTimeline(
|
||||
query: .init(local: true),
|
||||
query: .init(local: true, sinceID: sinceID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
@ -149,6 +154,8 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
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)
|
||||
|
|
|
@ -79,7 +79,8 @@ extension MastodonFeed: Hashable {
|
|||
lhs.status?.poll == rhs.status?.poll &&
|
||||
lhs.status?.reblog?.poll == rhs.status?.reblog?.poll &&
|
||||
lhs.status?.poll?.entity == rhs.status?.poll?.entity &&
|
||||
lhs.status?.reblog?.poll?.entity == rhs.status?.reblog?.poll?.entity
|
||||
lhs.status?.reblog?.poll?.entity == rhs.status?.reblog?.poll?.entity &&
|
||||
lhs.isLoadingMore == rhs.isLoadingMore
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
|
@ -94,6 +95,7 @@ extension MastodonFeed: Hashable {
|
|||
hasher.combine(status?.reblog?.poll)
|
||||
hasher.combine(status?.poll?.entity)
|
||||
hasher.combine(status?.reblog?.poll?.entity)
|
||||
hasher.combine(isLoadingMore)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue