Skip to content

Commit

Permalink
fixed dupes in profile feed (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews authored Feb 9, 2024
1 parent eb20991 commit 6c6ab8f
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions Mlem/Views/Tabs/Profile/UserView+Logic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,13 @@ extension UserView {

communityTracker.replaceAll(with: user.moderatedCommunities ?? [])

var savedContentData: GetPersonDetailsResponse?
if isOwnProfile {
savedContentData = try await personRepository.loadUserDetails(
for: user.userId,
limit: internetSpeed.pageSize,
savedOnly: true
)
}

// accumulate comments and posts so we don't update state more than we need to
var newComments = authoredContent.comments
.sorted(by: { $0.comment.published > $1.comment.published })
.map { HierarchicalComment(comment: $0, children: [], parentCollapsed: false, collapsed: false) }

var newPosts = authoredContent.posts.map { PostModel(from: $0) }

// add saved content, if present
if let savedContent = savedContentData {
newComments.append(contentsOf:
savedContent.comments
.sorted(by: { $0.comment.published > $1.comment.published })
.map { HierarchicalComment(comment: $0, children: [], parentCollapsed: false, collapsed: false) })

newPosts.append(contentsOf: savedContent.posts.map { PostModel(from: $0) })
}

privateCommentTracker.comments = newComments
await privatePostTracker.reset(with: newPosts)

Expand Down

0 comments on commit 6c6ab8f

Please sign in to comment.