fuzzysearch username -> display_name
This commit is contained in:
@ -3,12 +3,12 @@ import Fuse from "fuse.js";
|
|||||||
export type FuzzySearchResult = {
|
export type FuzzySearchResult = {
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
username?: string;
|
display_name?: string;
|
||||||
nip05?: string;
|
nip05?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fuzzySearch = new Fuse<FuzzySearchResult>([], {
|
const fuzzySearch = new Fuse<FuzzySearchResult>([], {
|
||||||
keys: ["name", "username", { name: "nip05", weight: 0.5 }],
|
keys: ["name", "display_name", { name: "nip05", weight: 0.5 }],
|
||||||
threshold: 0.3,
|
threshold: 0.3,
|
||||||
// sortFn here?
|
// sortFn here?
|
||||||
});
|
});
|
||||||
@ -29,7 +29,7 @@ export const addEventToFuzzySearch = ev => {
|
|||||||
profileTimestamps.set(ev.pubkey, ev.created_at);
|
profileTimestamps.set(ev.pubkey, ev.created_at);
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(ev.content);
|
const data = JSON.parse(ev.content);
|
||||||
if (ev.pubkey && (data.name || data.username || data.nip05)) {
|
if (ev.pubkey && (data.name || data.display_name || data.nip05)) {
|
||||||
data.pubkey = ev.pubkey;
|
data.pubkey = ev.pubkey;
|
||||||
fuzzySearch.add(data);
|
fuzzySearch.add(data);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user