mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-09-03 00:23:49 +00:00
Handle account link in account bio and notifications
This commit is contained in:
parent
28ef54fa4b
commit
975a403c49
1 changed files with 9 additions and 1 deletions
|
@ -68,6 +68,12 @@ public class RouterPath: ObservableObject {
|
||||||
let tag = url.pathComponents.last {
|
let tag = url.pathComponents.last {
|
||||||
navigate(to: .hashTag(tag: tag, account: nil))
|
navigate(to: .hashTag(tag: tag, account: nil))
|
||||||
return .handled
|
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
|
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 }
|
guard let client else { return }
|
||||||
Task {
|
Task {
|
||||||
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: acct,
|
let results: SearchResults? = try? await client.get(endpoint: Search.search(query: acct,
|
||||||
|
@ -98,6 +104,8 @@ public class RouterPath: ObservableObject {
|
||||||
forceVersion: .v2)
|
forceVersion: .v2)
|
||||||
if let account = results?.accounts.first {
|
if let account = results?.accounts.first {
|
||||||
navigate(to: .accountDetailWithAccount(account: account))
|
navigate(to: .accountDetailWithAccount(account: account))
|
||||||
|
} else {
|
||||||
|
await UIApplication.shared.open(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue