From caab123781f92eeb958514c19308bf88922ce7e4 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 21 Aug 2023 18:03:05 -0400 Subject: [PATCH] update check for notification handler --- MVMCoreUI/Notification/NotificationHandler.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Notification/NotificationHandler.swift b/MVMCoreUI/Notification/NotificationHandler.swift index 627d611a..8971bd5a 100644 --- a/MVMCoreUI/Notification/NotificationHandler.swift +++ b/MVMCoreUI/Notification/NotificationHandler.swift @@ -357,15 +357,14 @@ open class NotificationHandler { /// Registers to know when pages change. private func registerForPageChanges() { cancellable = NavigationHandler.shared().onNavigationDidFinish.sink { [weak self] operation in - // Update displayable for each top alert operation when page type changes, in top queue priority order. - guard let self = self, - self.queue.operations.count > 0, - let navigationController = operation.navigationType.getNavigationController(), - navigationController == MVMCoreUISplitViewController.main()?.navigationController, - let viewController = navigationController.viewControllers.last, - let traversedController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return } - let pageType = (traversedController as? MVMCoreViewControllerProtocol)?.pageType + guard let self = self else { return } Task { + // Update displayable for each top alert operation when page type changes, in top queue priority order. + guard self.queue.operations.count > 0, + let navigationController = await operation.navigationType.getNavigationController(), + await navigationController == MVMCoreUISplitViewController.main()?.navigationController, + let viewController = await navigationController.getViewController() else { return } + let pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType self.queue.operations.compactMap { $0 as? NotificationOperation }.sorted {