Fix UI bug with user search and fix race conditions on profiles NIP-05 cache
Signed-off-by: Terry Yiu <git@tyiu.xyz> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -726,7 +726,7 @@ func process_metadata_profile(our_pubkey: String, profiles: Profiles, profile: P
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
profiles.validated[ev.pubkey] = validated
|
||||
profiles.set_validated(ev.pubkey, nip05: validated)
|
||||
profiles.nip05_pubkey[nip05] = ev.pubkey
|
||||
notify(.profile_updated, ProfileUpdate(pubkey: ev.pubkey, profile: profile))
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ extension Trie {
|
||||
}
|
||||
|
||||
// Perform breadth-first search from matching branch and collect values from all descendants.
|
||||
let exactMatches = Array(currentNode.exactMatchValues)
|
||||
var substringMatches = Set<V>(currentNode.substringMatchValues)
|
||||
var queue = Array(currentNode.children.values)
|
||||
|
||||
@@ -61,7 +60,8 @@ extension Trie {
|
||||
queue.append(contentsOf: node.children.values)
|
||||
}
|
||||
|
||||
return exactMatches + substringMatches
|
||||
// Prioritize exact matches to be returned first, and then remove exact matches from the set of partial substring matches that are appended afterward.
|
||||
return Array(currentNode.exactMatchValues) + (substringMatches.subtracting(currentNode.exactMatchValues))
|
||||
}
|
||||
|
||||
/// Inserts value of type V into this trie for the specified key. This function stores all substring endings of the key, not only the key itself.
|
||||
|
||||
Reference in New Issue
Block a user