Skip to content

Commit

Permalink
fixed comments not showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Oct 6, 2023
1 parent 2635597 commit 059a36c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Mlem/Views/Tabs/Profile/User View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,26 @@ struct UserView: View {
appState.setActiveAccount(updatedAccount)
}

privateCommentTracker.comments = authoredContent.comments
// 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) }

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

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

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

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

userDetails = authoredContent.personView
moderatedCommunities = authoredContent.moderates
updateAvatarSubtext()
Expand Down

0 comments on commit 059a36c

Please sign in to comment.