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

Fix comments not loading when opening post from link #1522

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 9 additions & 6 deletions Mlem/App/Views/Shared/ExpandedPost/CommentPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,21 @@ struct CommentPage: View {
if let comment = model.wrappedValue as? any Comment {
if let tracker {
tracker.root = .comment(comment, parentCount: 1)
Task {
if let initialComments {
if let initialComments {
Task {
await tracker.insertAdditionalComments(comments: initialComments)
tracker.loadingState = .done
} else {
tracker.loadingState = .idle
await tracker.load()
}
tracker.loadingState = .done
return
} else {
tracker.loadingState = .idle
}
} else {
tracker = .init(root: .comment(comment, parentCount: 1))
}
Task {
await tracker?.load()
}
}
}
.background(palette.groupedBackground)
Expand Down
6 changes: 3 additions & 3 deletions Mlem/App/Views/Shared/ExpandedPost/PostPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ struct PostPage: View {
if let tracker {
tracker.root = .post(post)
tracker.loadingState = .idle
Task {
await tracker.load(ensuringPresenceOf: scrollTargetedComment)
}
} else {
tracker = .init(root: .post(post))
}
Task {
await tracker?.load(ensuringPresenceOf: scrollTargetedComment)
}
}
}
.background(palette.groupedBackground)
Expand Down
Loading