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 {