Skip to content

Commit

Permalink
fix navigationstate crash
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmaccallum committed Dec 10, 2024
1 parent 4f845b5 commit d7bdc26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ struct ReleaseWidget: ParraContainer {

@Environment(\.parraComponentFactory) private var componentFactory
@Environment(\.parraConfiguration) private var parraConfiguration

@Environment(\.parraTheme) private var parraTheme
@Environment(NavigationState.self) private var navigationState

@State private var navigationState = NavigationState()
}
37 changes: 20 additions & 17 deletions ios/Sources/Parra/Core/Parra App/ParraApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private func getParraInternalSingleton(
public struct ParraApp<
Content: Scene,
SceneDelegateClass: ParraSceneDelegate
>: Scene {
>: Scene, @preconcurrency Equatable {
// MARK: - Lifecycle

public init() {
Expand Down Expand Up @@ -137,16 +137,16 @@ public struct ParraApp<
public var body: some Scene {
makeScene()
.environment(\.parra, Parra.default)
.environment(\.parraAuthState, authStateManager.current)
.environment(\.parraAuthState, ParraAuthStateManager.shared.current)
.environment(\.parraComponentFactory, parraInternal.globalComponentFactory)
.environment(\.parraConfiguration, parraInternal.configuration)
.environment(\.parraTheme, themeManager.current)
.environment(\.parraUserProperties, userProperties)
.environment(\.parraTheme, ParraThemeManager.shared.current)
.environment(\.parraUserProperties, ParraUserProperties.shared)
.environment(
\.parraPreferredAppearance,
themeManager.preferredAppearanceBinding
ParraThemeManager.shared.preferredAppearanceBinding
)
.environment(\.parraAlertManager, alertManager)
.environment(\.parraAlertManager, ParraAlertManager.shared)
.environment(launchScreenState)
.onChange(
of: launchScreenState.current,
Expand All @@ -160,7 +160,7 @@ public struct ParraApp<
// performAppLaunchTasks completing changes the launch
// screen state to transitioning, allowing this to start
if result.requiresAuthRefresh {
authStateManager.triggerAuthRefresh(
ParraAuthStateManager.shared.triggerAuthRefresh(
using: parraInternal.authService
)
}
Expand All @@ -169,7 +169,7 @@ public struct ParraApp<
}
}
.onChange(
of: authStateManager.current,
of: ParraAuthStateManager.shared.current,
onAuthStateChanged
)
.onChange(
Expand All @@ -187,6 +187,13 @@ public struct ParraApp<
}
}

public static func == (
lhs: ParraApp<Content, SceneDelegateClass>,
rhs: ParraApp<Content, SceneDelegateClass>
) -> Bool {
return true
}

// MARK: - Private

@Environment(\.scenePhase) private var scenePhase
Expand All @@ -196,11 +203,6 @@ public struct ParraApp<
@State private var urlHandler: ((URL) -> Void)?

@State private var launchScreenState: LaunchScreenStateManager
@State private var alertManager: ParraAlertManager = .shared
@State private var authStateManager: ParraAuthStateManager = .shared
@State private var themeManager: ParraThemeManager = .shared
@State private var userProperties: ParraUserProperties = .shared

@State private var parraInternal: ParraInternal!

private func onAuthStateChanged(
Expand Down Expand Up @@ -246,10 +248,11 @@ public struct ParraApp<
logger.debug("Post app launch actions complete")

logger.debug("Performing initial auth state load")
let authResult = try await authStateManager.performInitialAuthCheck(
using: parraInternal.authService,
appInfo: result.appInfo
)
let authResult = try await ParraAuthStateManager.shared
.performInitialAuthCheck(
using: parraInternal.authService,
appInfo: result.appInfo
)

result.requiresAuthRefresh = authResult.requiresRefresh

Expand Down

0 comments on commit d7bdc26

Please sign in to comment.