Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed dupes in profile feed #920

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading