Tweak internal/external deeplink handling (#2664)

* Add a childRoom AppRoute.

* Add a tests for child room routes.
This commit is contained in:
Doug
2024-04-08 16:44:03 +01:00
committed by GitHub
parent 446aab58de
commit 761824fa0d
9 changed files with 86 additions and 14 deletions
@@ -176,7 +176,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
)
}
func handleDeepLink(_ url: URL) -> Bool {
func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool {
// Parse into an AppRoute to redirect these in a type safe way.
if let route = appRouteURLParser.route(from: url) {
@@ -193,8 +193,14 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
} else {
navigationRootCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)))
}
case .roomMemberDetails, .room:
case .roomMemberDetails:
userSessionFlowCoordinator?.handleAppRoute(route, animated: true)
case .room(let roomID):
if isExternalURL {
userSessionFlowCoordinator?.handleAppRoute(route, animated: true)
} else {
userSessionFlowCoordinator?.handleAppRoute(.childRoom(roomID: roomID), animated: true)
}
default:
break
}
@@ -18,5 +18,5 @@ import Foundation
protocol AppCoordinatorProtocol: CoordinatorProtocol {
var windowManager: WindowManagerProtocol { get }
@discardableResult func handleDeepLink(_ url: URL) -> Bool
@discardableResult func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool
}
@@ -40,14 +40,14 @@ struct Application: App {
appCoordinator.toPresentable()
.statusBarHidden(shouldHideStatusBar)
.environment(\.openURL, OpenURLAction { url in
if appCoordinator.handleDeepLink(url) {
if appCoordinator.handleDeepLink(url, isExternalURL: false) {
return .handled
}
return .systemAction
})
.onOpenURL {
if !appCoordinator.handleDeepLink($0) {
if !appCoordinator.handleDeepLink($0, isExternalURL: true) {
openURLInSystemBrowser($0)
}
}
@@ -17,13 +17,24 @@
import Foundation
enum AppRoute: Equatable {
/// The callback used to complete login with OIDC.
case oidcCallback(url: URL)
/// The app's home screen.
case roomList
/// A room, shown as the root of the stack (popping any child rooms).
case room(roomID: String)
/// A room, pushed as a child of any existing rooms on the stack.
case childRoom(roomID: String)
/// The information about a particular room.
case roomDetails(roomID: String)
/// The profile of a member within the current room.
/// (This can be specialised into 2 routes when we support user permalinks).
case roomMemberDetails(userID: String)
/// An Element Call link generated outside of a chat room.
case genericCallLink(url: URL)
/// The settings screen.
case settings
/// The setting screen for key backup.
case chatBackupSettings
}