Skip to content

Commit

Permalink
home: work around crash on visionOS
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Apr 20, 2024
1 parent 99d35fc commit 11cf8af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Platform/Shared/VMDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,19 @@ struct VMDetailsView: View {

private extension View {
func taskOnAppear<T>(id value: T, priority: TaskPriority = .userInitiated, _ action: @escaping @Sendable @MainActor () async -> Void) -> some View where T : Equatable & Hashable {
#if os(visionOS) // FIXME: visionOS crashes with task()
self.onAppear {
Task(priority: priority, operation: action)
}.id(value)
#else
if #available(macOS 12, iOS 15, *) {
return self.task(id: value, priority: priority, action)
} else {
return self.onAppear {
Task(priority: priority, operation: action)
}.id(value)
}
#endif
}
}

Expand Down

0 comments on commit 11cf8af

Please sign in to comment.