show "followed by" on profile pages

This commit is contained in:
Martti Malmi
2023-11-24 16:18:32 +02:00
parent 47aec5437d
commit 13b76e7709
5 changed files with 56 additions and 8 deletions

View File

@ -50,10 +50,12 @@ export default function SearchBox() {
const combinedResults = fuseResults.map(result => {
const fuseScore = result.score === undefined ? 1 : result.score;
const followDistance = socialGraphInstance.getFollowDistance(result.item.pubkey) / followDistanceNormalizationFactor;
const followDistance =
socialGraphInstance.getFollowDistance(result.item.pubkey) / followDistanceNormalizationFactor;
const startsWithSearchString = [result.item.name, result.item.display_name, result.item.nip05]
.some(field => field && field.toLowerCase?.().startsWith(searchString.toLowerCase()));
const startsWithSearchString = [result.item.name, result.item.display_name, result.item.nip05].some(
field => field && field.toLowerCase?.().startsWith(searchString.toLowerCase()),
);
const boostFactor = startsWithSearchString ? 0.25 : 1;
@ -65,12 +67,11 @@ export default function SearchBox() {
return { ...result, combinedScore };
});
// Sort by combined score, lower is better
combinedResults.sort((a, b) => a.combinedScore - b.combinedScore);
setResults(combinedResults.map(r => r.item));
}, [search, main]);
// Sort by combined score, lower is better
combinedResults.sort((a, b) => a.combinedScore - b.combinedScore);
setResults(combinedResults.map(r => r.item));
}, [search, main]);
useEffect(() => {
const handleGlobalKeyDown = (e: KeyboardEvent) => {