Skip to content

Commit

Permalink
Fix crash in PostSearchViewModel (#23247)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed May 23, 2024
2 parents f57ccad + be5aa1b commit 892c8ee
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ final class PostSearchService {
offset += posts.count
hasMore = !posts.isEmpty

let newPosts = posts.filter { !postIDs.contains($0.objectID) }
let newPosts = posts
.deduplicated(by: \.objectID)
.filter { !postIDs.contains($0.objectID) }
postIDs.formUnion(newPosts.map(\.objectID))
self.delegate?.service(self, didAppendPosts: newPosts)
case .failure(let error):
Expand Down

0 comments on commit 892c8ee

Please sign in to comment.