diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2025-01-14 11:49:21 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-01-14 11:49:21 +0100 |
| commit | ed0b9cd0283e26e216fbb7edf5cd6e5bcf042cde (patch) | |
| tree | 6fc5be4a68ffde2337d1bc3bb516ff46144a07be /ios/Routing/Router/ApplicationRouter.swift | |
| parent | d2949b4a0b1d3d86a25de1569dc8308c9d7fe237 (diff) | |
| parent | e71db0cfc12bd561532b73722983175edab2482c (diff) | |
| download | mullvadvpn-ed0b9cd0283e26e216fbb7edf5cd6e5bcf042cde.tar.xz mullvadvpn-ed0b9cd0283e26e216fbb7edf5cd6e5bcf042cde.zip | |
Merge branch 'fix-warnings-introduced-by-xcode-16-ios-741'
Diffstat (limited to 'ios/Routing/Router/ApplicationRouter.swift')
| -rw-r--r-- | ios/Routing/Router/ApplicationRouter.swift | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/ios/Routing/Router/ApplicationRouter.swift b/ios/Routing/Router/ApplicationRouter.swift index d565875143..c55daf2400 100644 --- a/ios/Routing/Router/ApplicationRouter.swift +++ b/ios/Routing/Router/ApplicationRouter.swift @@ -13,8 +13,9 @@ import UIKit /** Main application router. */ -public final class ApplicationRouter<RouteType: AppRouteProtocol> { - private let logger = Logger(label: "ApplicationRouter") +@MainActor +public final class ApplicationRouter<RouteType: AppRouteProtocol>: Sendable { + nonisolated(unsafe) private let logger = Logger(label: "ApplicationRouter") private(set) var modalStack: [RouteType.RouteGroupType] = [] private(set) var presentedRoutes: [RouteType.RouteGroupType: [PresentedRoute<RouteType>]] = [:] @@ -95,7 +96,7 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { _ route: RouteType, animated: Bool, metadata: Any?, - completion: @escaping (PendingPresentationResult) -> Void + completion: @escaping @Sendable @MainActor (PendingPresentationResult) -> Void ) { /** Pass sub-route for routes supporting sub-navigation. @@ -160,15 +161,19 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { /* Synchronize router when modal controllers are removed by swipe. */ - if let presentable = coordinator as? Presentable { - presentable.onInteractiveDismissal { [weak self] coordinator in - self?.handleInteractiveDismissal(route: route, coordinator: coordinator) + MainActor.assumeIsolated { + if let presentable = coordinator as? Presentable { + presentable.onInteractiveDismissal { [weak self] coordinator in + MainActor.assumeIsolated { + self?.handleInteractiveDismissal(route: route, coordinator: coordinator) + } + } } - } - self.addPresentedRoute(PresentedRoute(route: route, coordinator: coordinator)) + self.addPresentedRoute(PresentedRoute(route: route, coordinator: coordinator)) - completion(.success) + completion(.success) + } } } else { completion(.drop) @@ -178,7 +183,7 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { private func dismissGroup( _ dismissGroup: RouteType.RouteGroupType, animated: Bool, - completion: @escaping (PendingDismissalResult) -> Void + completion: @escaping @Sendable (PendingDismissalResult) -> Void ) { /** Check if routes corresponding to the group requested for dismissal are present. @@ -224,7 +229,7 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { private func dismissRoute( _ dismissRoute: RouteType, animated: Bool, - completion: @escaping (PendingDismissalResult) -> Void + completion: @escaping @Sendable (PendingDismissalResult) -> Void ) { var routes = presentedRoutes[dismissRoute.routeGroup] ?? [] @@ -304,19 +309,21 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { case let .dismiss(dismissMatch): handleDismissal(dismissMatch, animated: pendingRoute.animated) { result in - switch result { - case .success, .drop: - self.finishPendingRoute(pendingRoute) + MainActor.assumeIsolated { + switch result { + case .success, .drop: + self.finishPendingRoute(pendingRoute) - case .blockedByModalAbove: - /** - If router cannot dismiss modal because there is one above, - try walking down the queue and see if there is a dismissal request that could - resolve that. - */ - self.processPendingRoutes( - skipRouteGroups: skipRouteGroups.union([dismissMatch.routeGroup]) - ) + case .blockedByModalAbove: + /** + If router cannot dismiss modal because there is one above, + try walking down the queue and see if there is a dismissal request that could + resolve that. + */ + self.processPendingRoutes( + skipRouteGroups: skipRouteGroups.union([dismissMatch.routeGroup]) + ) + } } } } @@ -325,7 +332,7 @@ public final class ApplicationRouter<RouteType: AppRouteProtocol> { private func handleDismissal( _ dismissMatch: DismissMatch<RouteType>, animated: Bool, - completion: @escaping (PendingDismissalResult) -> Void + completion: @escaping @Sendable (PendingDismissalResult) -> Void ) { switch dismissMatch { case let .singleRoute(route): |
