From 792db567edc6267417d6fc3bac659bacf31d3e70 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 6 Jan 2022 17:06:03 +0100 Subject: [PATCH] Fix manage object context in tvOS info view controllers --- Shared/Player/PlayerViewController.swift | 3 +++ tvOS/TVNavigationView.swift | 1 + 2 files changed, 4 insertions(+) diff --git a/Shared/Player/PlayerViewController.swift b/Shared/Player/PlayerViewController.swift index 088fadd4..8146ff1b 100644 --- a/Shared/Player/PlayerViewController.swift +++ b/Shared/Player/PlayerViewController.swift @@ -10,6 +10,8 @@ final class PlayerViewController: UIViewController { var subscriptionsModel: SubscriptionsModel! var playerView = AVPlayerViewController() + let persistenceController = PersistenceController.shared + #if !os(tvOS) var aspectRatio: Double? { let ratio = Double(playerView.videoBounds.width) / Double(playerView.videoBounds.height) @@ -95,6 +97,7 @@ final class PlayerViewController: UIViewController { .environmentObject(commentsModel) .environmentObject(playerModel) .environmentObject(subscriptionsModel) + .environment(\.managedObjectContext, persistenceController.container.viewContext) ) ) diff --git a/tvOS/TVNavigationView.swift b/tvOS/TVNavigationView.swift index f9931eb4..7adaa941 100644 --- a/tvOS/TVNavigationView.swift +++ b/tvOS/TVNavigationView.swift @@ -8,6 +8,7 @@ struct TVNavigationView: View { @EnvironmentObject private var recents @Default(.visibleSections) private var visibleSections + var body: some View { TabView(selection: navigation.tabSelectionBinding) { if visibleSections.contains(.favorites) {