diff --git a/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift b/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift index c4b3c11..4b2d9f9 100644 --- a/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift +++ b/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift @@ -14,7 +14,6 @@ public final class RootViewModel: ObservableObject { private let userNotificationService: UserNotificationService private let registerForRemoteNotifications: () -> AnyPublisher private var cancellables = Set() - private var navigationViewModelCancellable: AnyCancellable? public init(environment: AppEnvironment, registerForRemoteNotifications: @escaping () -> AnyPublisher) throws { @@ -96,8 +95,8 @@ private extension RootViewModel { } .share() - navigationViewModelCancellable = identityPublisher - .filter { [weak self] in $0.id != self?.navigationViewModel?.identityContext.identity.id } + identityPublisher + .first() .map { [weak self] in guard let self = self else { return nil } @@ -122,6 +121,6 @@ private extension RootViewModel { return NavigationViewModel(identityContext: identityContext) } - .sink { [weak self] in self?.navigationViewModel = $0 } + .assign(to: &$navigationViewModel) } }