mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix a couple of crashes on macOS from a missing environment object. (#4153)
This commit is contained in:
@@ -14,6 +14,10 @@ struct TimelineView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
TimelineViewRepresentable()
|
TimelineViewRepresentable()
|
||||||
.id(timelineContext.viewState.roomID)
|
.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)
|
.environment(\.focussedEventID, timelineContext.viewState.timelineState.focussedEvent?.eventID)
|
||||||
.alert(item: $timelineContext.alertInfo)
|
.alert(item: $timelineContext.alertInfo)
|
||||||
.sheet(item: $timelineContext.manageMemberViewModel) {
|
.sheet(item: $timelineContext.manageMemberViewModel) {
|
||||||
@@ -33,6 +37,7 @@ struct TimelineView: View {
|
|||||||
.makeActions()
|
.makeActions()
|
||||||
if let actions {
|
if let actions {
|
||||||
TimelineItemMenu(item: info.item, actions: actions)
|
TimelineItemMenu(item: info.item, actions: actions)
|
||||||
|
.environmentObject(timelineContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $timelineContext.reactionSummaryInfo) {
|
.sheet(item: $timelineContext.reactionSummaryInfo) {
|
||||||
@@ -44,10 +49,8 @@ struct TimelineView: View {
|
|||||||
}
|
}
|
||||||
.sheet(item: $timelineContext.readReceiptsSummaryInfo) {
|
.sheet(item: $timelineContext.readReceiptsSummaryInfo) {
|
||||||
ReadReceiptsSummaryView(orderedReadReceipts: $0.orderedReceipts)
|
ReadReceiptsSummaryView(orderedReadReceipts: $0.orderedReceipts)
|
||||||
|
.environmentObject(timelineContext)
|
||||||
}
|
}
|
||||||
// Ensure these are available in the sheets as well. The order is important.
|
|
||||||
.environmentObject(timelineContext)
|
|
||||||
.environment(\.timelineContext, timelineContext)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user