ONEAPP-5208: Review feedback

This commit is contained in:
Scott Pfeil 2023-08-28 11:13:40 -04:00
parent caab123781
commit e8fcf1ac5d
2 changed files with 20 additions and 20 deletions

View File

@ -43,11 +43,13 @@ import Combine
*/ */
@MainActor @MainActor
public func subscribe() { public func subscribe() {
NavigationHandler.shared().onNavigationWillBegin.sink { [weak self] operation in NavigationHandler.shared().onNavigation.sink { [weak self] (event, operation) in
guard let self = self, guard let self = self,
self == operation.navigationType.getNavigationController(), self == operation.navigationType.getNavigationController(),
let viewController = NavigationHandler.shared().getViewControllers(for: self).last, let viewController = NavigationHandler.shared().getViewControllers(for: self).last,
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return }
switch event {
case .willNavigate:
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller) MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller)
} }
@ -56,17 +58,13 @@ import Combine
self.setNavigationBarUI(with: model) self.setNavigationBarUI(with: model)
} }
self.manager?.willDisplay?(newViewController) self.manager?.willDisplay?(newViewController)
}.store(in: &cancellables) case .didNavigate:
NavigationHandler.shared().onNavigationDidFinish.sink { [weak self] operation in
guard let self = self,
self == operation.navigationType.getNavigationController(),
let viewController = NavigationHandler.shared().getViewControllers(for: self).last,
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return }
self.manager?.displayedViewController?(newViewController) self.manager?.displayedViewController?(newViewController)
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) { if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
controller.viewControllerReady?(inManager: self) controller.viewControllerReady?(inManager: self)
} }
@unknown default: break
}
}.store(in: &cancellables) }.store(in: &cancellables)
} }

View File

@ -356,7 +356,9 @@ open class NotificationHandler {
/// Registers to know when pages change. /// Registers to know when pages change.
private func registerForPageChanges() { private func registerForPageChanges() {
cancellable = NavigationHandler.shared().onNavigationDidFinish.sink { [weak self] operation in cancellable = NavigationHandler.shared().onNavigation
.filter({ $0.0 == .didNavigate })
.sink { [weak self] (event, operation) in
guard let self = self else { return } guard let self = self else { return }
Task { Task {
// Update displayable for each top alert operation when page type changes, in top queue priority order. // Update displayable for each top alert operation when page type changes, in top queue priority order.