search: switch to nostrdb profile searching

Changelog-Changed: Switch to nostrdb for @'s and user search
This commit is contained in:
William Casarin
2023-09-21 13:19:22 -04:00
parent fafe3b4b3e
commit 7a85ae29ca
11 changed files with 325 additions and 33 deletions

View File

@@ -38,10 +38,7 @@ class Profiles {
@MainActor
var nip05_pubkey: [String: Pubkey] = [:]
let user_search_cache: UserSearchCache
init(user_search_cache: UserSearchCache, ndb: Ndb) {
self.user_search_cache = user_search_cache
init(ndb: Ndb) {
self.ndb = ndb
}
@@ -84,6 +81,10 @@ class Profiles {
return ndb.lookup_profile_by_key(key: key)
}
func search<Y>(_ query: String, limit: Int, txn: NdbTxn<Y>) -> [Pubkey] {
return ndb.search_profile(query, limit: limit, txn: txn)
}
func lookup(id: Pubkey) -> NdbTxn<Profile?> {
return ndb.lookup_profile(id).map({ pr in pr?.profile })
}