From 87df5a6e87dc3b782d8296588bb8ac4a83c04290 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Wed, 4 Jan 2023 16:38:30 -0800 Subject: [PATCH] Update default context for ManagedPlayer to use JSVirtualMachine --- .../Sources/ManagedPlayer/ManagedPlayer.swift | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ios/packages/swiftui/Sources/ManagedPlayer/ManagedPlayer.swift b/ios/packages/swiftui/Sources/ManagedPlayer/ManagedPlayer.swift index 54449218e..d096a4ea0 100644 --- a/ios/packages/swiftui/Sources/ManagedPlayer/ManagedPlayer.swift +++ b/ios/packages/swiftui/Sources/ManagedPlayer/ManagedPlayer.swift @@ -128,11 +128,6 @@ internal struct ManagedPlayer14: View { private var handleScroll: Bool - // Whether or not its a the start of a new flow - // once the animation has been shown we need to remove it - // otherwise you get flickering double transitions between views in a flow - @State private var newFlow = true - /** Creates a `ManagedPlayer` - parameters: @@ -192,8 +187,7 @@ internal struct ManagedPlayer14: View { flow: flow, plugins: plugins + [viewModel] + (handleScroll ? [ScrollPlugin()] : []), result: $viewModel.result, - context: context, - unloadOnDisappear: false + context: context ) } } @@ -211,7 +205,11 @@ public extension SwiftUIPlayer.Context { } private extension JSContext { - static let sharedManaged: JSContext! = JSContext() + static var sharedManaged: JSContext! { JSContext(virtualMachine: .playerShared) } +} + +private extension JSVirtualMachine { + static let playerShared: JSVirtualMachine = .init() } internal struct ManagedPlayer13: View { @@ -225,11 +223,6 @@ internal struct ManagedPlayer13: View { private var handleScroll: Bool - // Whether or not its a the start of a new flow - // once the animation has been shown we need to remove it - // otherwise you get flickering double transitions between views in a flow - @State private var newFlow = true - // For ViewInspector testing internal let inspection = Inspection() @@ -293,8 +286,7 @@ internal struct ManagedPlayer13: View { flow: flow, plugins: plugins + [viewModel] + (handleScroll ? [ScrollPlugin()] : []), result: $viewModel.result, - context: context, - unloadOnDisappear: false + context: context ) } }