Skip to content

Fix a couple of crashes on macOS from a missing environment object. #4153

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

Merged
merged 1 commit into from
May 28, 2025
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
9 changes: 6 additions & 3 deletions ElementX/Sources/Screens/Timeline/View/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ struct TimelineView: View {
var body: some View {
TimelineViewRepresentable()
.id(timelineContext.viewState.roomID)
// It is tempting to inject these environment values last to avoid also injecting them into the sheets,
// and that approach works great on iOS. But it doesn't work on macOS (as of 15.5) where the app goes 💥
.environmentObject(timelineContext)
.environment(\.timelineContext, timelineContext)
.environment(\.focussedEventID, timelineContext.viewState.timelineState.focussedEvent?.eventID)
.alert(item: $timelineContext.alertInfo)
.sheet(item: $timelineContext.manageMemberViewModel) {
Expand All @@ -33,6 +37,7 @@ struct TimelineView: View {
.makeActions()
if let actions {
TimelineItemMenu(item: info.item, actions: actions)
.environmentObject(timelineContext)
}
}
.sheet(item: $timelineContext.reactionSummaryInfo) {
Expand All @@ -44,10 +49,8 @@ struct TimelineView: View {
}
.sheet(item: $timelineContext.readReceiptsSummaryInfo) {
ReadReceiptsSummaryView(orderedReadReceipts: $0.orderedReceipts)
.environmentObject(timelineContext)
}
// Ensure these are available in the sheets as well. The order is important.
.environmentObject(timelineContext)
.environment(\.timelineContext, timelineContext)
}
}

Expand Down
Loading