diff --git a/Ring/Ring/Coordinators/AppCoordinator.swift b/Ring/Ring/Coordinators/AppCoordinator.swift index fa122d1ab09f69a38570abfa3afa33f9b791941f..98184ae3c19a8a144b6acaac21410a896f6a6d97 100644 --- a/Ring/Ring/Coordinators/AppCoordinator.swift +++ b/Ring/Ring/Coordinators/AppCoordinator.swift @@ -102,12 +102,6 @@ final class AppCoordinator: Coordinator, StateableResponsive { self.dispatchApplication() } - /// Starts the coordinator - func startWithoutLoading() { - // ~ Dispatch to the proper screen - self.dispatchApplication() - } - func migrateAccount(accountId: String) { let migratonController = MigrateAccountViewController.instantiate(with: self.injectionBag) migratonController.viewModel.accountToMigrate = accountId @@ -145,16 +139,22 @@ final class AppCoordinator: Coordinator, StateableResponsive { let walkthroughCoordinator = WalkthroughCoordinator(with: self.injectionBag) walkthroughCoordinator.isAccountFirst = isAccountFirst walkthroughCoordinator.withAnimations = animated - walkthroughCoordinator.parentCoordinator = self walkthroughCoordinator.start() - self.navigationController.setViewControllers([], animated: false) self.addChildCoordinator(childCoordinator: walkthroughCoordinator) let walkthroughViewController = walkthroughCoordinator.rootViewController self.present(viewController: walkthroughViewController, withStyle: .appear, withAnimation: true, disposeBag: self.disposeBag) + + walkthroughViewController.rx.controllerWasDismissed + .subscribe(onNext: { [weak self, weak walkthroughCoordinator] (_) in + walkthroughCoordinator?.stateSubject.dispose() + self?.removeChildCoordinator(childCoordinator: walkthroughCoordinator) + self?.dispatchApplication() + }) + .disposed(by: self.disposeBag) } /// Presents the main interface diff --git a/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift b/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift index 697094367085334a2155cac2b563bab2e472cae4..c03f3107b2c86b40e29f3b1ae1f7f6e3ec7f788b 100644 --- a/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift +++ b/Ring/Ring/Features/Walkthrough/WalkthroughCoordinator.swift @@ -75,12 +75,8 @@ class WalkthroughCoordinator: Coordinator, StateableResponsive { self.showAddAccount(with: walkthroughType) case .accountCreated, .deviceLinked: if self.rootViewController.presentedViewController != nil { - if let appCoordinator = self.parentCoordinator as? AppCoordinator { - appCoordinator.startWithoutLoading() - appCoordinator.removeChildCoordinator(childCoordinator: self) - self.rootViewController.presentedViewController?.dismiss(animated: true) { - self.rootViewController.dismiss(animated: false) - } + self.rootViewController.dismiss(animated: true) { [weak self] in // dismiss the pop up form modal view + self?.rootViewController.dismiss(animated: true) // dismiss the welcome view and check for user account state } } case .walkthroughCanceled: