Add nip05 search

Changelog-Added: Added ability to lookup users by nip05 identifiers
This commit is contained in:
William Casarin
2023-03-29 19:24:06 -04:00
parent 9fef2f071a
commit 0a4e75bfec
7 changed files with 143 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ enum Search {
case hashtag(String)
case profile(String)
case note(String)
case nip05(String)
case hex(String)
}
@@ -41,6 +42,10 @@ struct SearchResultsView: View {
NavigationLink(destination: dst) {
Text("Search hashtag: #\(ht)", comment: "Navigation link to search hashtag.")
}
case .nip05(let addr):
SearchingEventView(state: damus_state, evid: addr, search_type: .nip05)
case .profile(let prof):
let decoded = try? bech32_decode(prof)
let hex = hex_encode(decoded!.data)
@@ -95,6 +100,12 @@ func search_for_string(profiles: Profiles, _ new: String) -> Search? {
return nil
}
let splitted = new.split(separator: "@")
if splitted.count == 2 {
return .nip05(new)
}
if new.first! == "#" {
let ht = String(new.dropFirst().filter{$0 != " "})
return .hashtag(ht)