From 975a403c49ad11a45011095b5702e11461447d44 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 1 Jan 2023 11:40:18 +0100 Subject: [PATCH] Handle account link in account bio and notifications --- Packages/Env/Sources/Env/Routeur.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Packages/Env/Sources/Env/Routeur.swift b/Packages/Env/Sources/Env/Routeur.swift index 0ba07e1c..398410e1 100644 --- a/Packages/Env/Sources/Env/Routeur.swift +++ b/Packages/Env/Sources/Env/Routeur.swift @@ -68,6 +68,12 @@ public class RouterPath: ObservableObject { let tag = url.pathComponents.last { navigate(to: .hashTag(tag: tag, account: nil)) return .handled + } else if url.lastPathComponent.first == "@", let host = url.host { + let acct = "\(url.lastPathComponent)@\(host)" + Task { + await navigateToAccountFrom(acct: acct, url: url) + } + return .handled } return .systemAction } @@ -88,7 +94,7 @@ public class RouterPath: ObservableObject { } } - public func navigateToAccountFrom(acct: String) async { + public func navigateToAccountFrom(acct: String, url: URL) async { guard let client else { return } Task { let results: SearchResults? = try? await client.get(endpoint: Search.search(query: acct, @@ -98,6 +104,8 @@ public class RouterPath: ObservableObject { forceVersion: .v2) if let account = results?.accounts.first { navigate(to: .accountDetailWithAccount(account: account)) + } else { + await UIApplication.shared.open(url) } } }