fix adding profiles to search
This commit is contained in:
@ -53,7 +53,6 @@ export const addCachedMetadataToFuzzySearch = (profile: CachedMetadata) => {
|
|||||||
profileTimestamps.set(profile.pubkey, profile.created);
|
profileTimestamps.set(profile.pubkey, profile.created);
|
||||||
if (profile.pubkey && (profile.name || profile.display_name || profile.nip05)) {
|
if (profile.pubkey && (profile.name || profile.display_name || profile.nip05)) {
|
||||||
fuzzySearch.add(profile);
|
fuzzySearch.add(profile);
|
||||||
console.log("added profile to fuzzy search", profile);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@ import { removeUndefined, throwIfOffline } from "@snort/shared";
|
|||||||
import { mapEventToProfile, NostrEvent, NostrSystem, ProfileLoaderService, socialGraphInstance } from "@snort/system";
|
import { mapEventToProfile, NostrEvent, NostrSystem, ProfileLoaderService, socialGraphInstance } from "@snort/system";
|
||||||
|
|
||||||
import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache";
|
import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache";
|
||||||
import { addEventToFuzzySearch } from "@/Db/FuzzySearch";
|
import { addCachedMetadataToFuzzySearch, addEventToFuzzySearch } from "@/Db/FuzzySearch";
|
||||||
import { LoginStore } from "@/Utils/Login";
|
import { LoginStore } from "@/Utils/Login";
|
||||||
import { hasWasm, WasmOptimizer } from "@/Utils/wasm";
|
import { hasWasm, WasmOptimizer } from "@/Utils/wasm";
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ if (CONFIG.httpCache) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
System.ProfileLoader.Cache.hook(() => {
|
setTimeout(() => {
|
||||||
System.ProfileLoader.Cache.takeSnapshot().forEach(a => {
|
System.UserProfileCache.snapshot().forEach(a => {
|
||||||
console.log("Profile: %O", a);
|
addCachedMetadataToFuzzySearch(a);
|
||||||
});
|
});
|
||||||
}, "profiles");
|
}, 2000);
|
||||||
|
|
||||||
export async function fetchProfile(key: string) {
|
export async function fetchProfile(key: string) {
|
||||||
try {
|
try {
|
||||||
|
2
packages/system/src/cache/user-metadata.ts
vendored
2
packages/system/src/cache/user-metadata.ts
vendored
@ -1,6 +1,5 @@
|
|||||||
import { CachedMetadata } from ".";
|
import { CachedMetadata } from ".";
|
||||||
import { fetchNip05Pubkey, FeedCache, LNURL, DexieTableLike } from "@snort/shared";
|
import { fetchNip05Pubkey, FeedCache, LNURL, DexieTableLike } from "@snort/shared";
|
||||||
import { addCachedMetadataToFuzzySearch } from "@snort/app/src/Db/FuzzySearch";
|
|
||||||
|
|
||||||
export class UserProfileCache extends FeedCache<CachedMetadata> {
|
export class UserProfileCache extends FeedCache<CachedMetadata> {
|
||||||
#zapperQueue: Array<{ pubkey: string; lnurl: string }> = [];
|
#zapperQueue: Array<{ pubkey: string; lnurl: string }> = [];
|
||||||
@ -22,7 +21,6 @@ export class UserProfileCache extends FeedCache<CachedMetadata> {
|
|||||||
if (follows) {
|
if (follows) {
|
||||||
await this.buffer(follows);
|
await this.buffer(follows);
|
||||||
}
|
}
|
||||||
this.snapshot().forEach(p => addCachedMetadataToFuzzySearch(p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(q: string): Promise<Array<CachedMetadata>> {
|
async search(q: string): Promise<Array<CachedMetadata>> {
|
||||||
|
@ -199,6 +199,10 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
|
|||||||
return this.#relayCache;
|
return this.#relayCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get UserProfileCache(): FeedCache<CachedMetadata> {
|
||||||
|
return this.#profileCache;
|
||||||
|
}
|
||||||
|
|
||||||
get Optimizer(): Optimizer {
|
get Optimizer(): Optimizer {
|
||||||
return this.#optimizer;
|
return this.#optimizer;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user