From dce94e7d7d6680a9198edc9fcdc5ee8d13dec749 Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:47:57 +0200 Subject: [PATCH] Tapping on room link (with roomID) (#1853) * room linking * chagelog --- ElementX/Sources/Application/AppCoordinator.swift | 2 +- .../Sources/Application/Navigation/AppRoutes.swift | 3 ++- UnitTests/Sources/AppRouteURLParserTests.swift | 12 ++++++++++++ changelog.d/pr-1853.feature | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelog.d/pr-1853.feature diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 6850b5188..a8e24b733 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -158,7 +158,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate, } else { navigationRootCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url))) } - case .roomMemberDetails: + case .roomMemberDetails, .room: userSessionFlowCoordinator?.handleAppRoute(route, animated: true) default: break diff --git a/ElementX/Sources/Application/Navigation/AppRoutes.swift b/ElementX/Sources/Application/Navigation/AppRoutes.swift index b217c4b3c..5ab60e053 100644 --- a/ElementX/Sources/Application/Navigation/AppRoutes.swift +++ b/ElementX/Sources/Application/Navigation/AppRoutes.swift @@ -115,7 +115,8 @@ struct MatrixPermalinkParser: URLParser { switch PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL) { case .userIdentifier(let userID): return .roomMemberDetails(userID: userID) - // Other cases will be handled in the future + case .roomIdentifier(let roomID): + return .room(roomID: roomID) default: return nil } diff --git a/UnitTests/Sources/AppRouteURLParserTests.swift b/UnitTests/Sources/AppRouteURLParserTests.swift index 7a0326875..44319eeb5 100644 --- a/UnitTests/Sources/AppRouteURLParserTests.swift +++ b/UnitTests/Sources/AppRouteURLParserTests.swift @@ -120,4 +120,16 @@ class AppRouteURLParserTests: XCTestCase { XCTAssertEqual(route, .roomMemberDetails(userID: userID)) } + + func testMatrixRoomIdentifierURL() { + let id = "!abcdefghijklmnopqrstuvwxyz1234567890:matrix.org" + guard let url = URL(string: "\(appSettings.permalinkBaseURL)/#/\(id)") else { + XCTFail("Invalid url") + return + } + + let route = appRouteURLParser.route(from: url) + + XCTAssertEqual(route, .room(roomID: id)) + } } diff --git a/changelog.d/pr-1853.feature b/changelog.d/pr-1853.feature new file mode 100644 index 000000000..0c4aed5bc --- /dev/null +++ b/changelog.d/pr-1853.feature @@ -0,0 +1 @@ +Tapping on matrix room id link brings you to that room. \ No newline at end of file