1
0
forked from Kieran/snort

on init, load cached profiles to fuzzy search

This commit is contained in:
Martti Malmi 2024-01-09 12:38:24 +02:00
parent 45245153ab
commit 6026ed34a8
3 changed files with 8 additions and 1 deletions

View File

@ -42,7 +42,6 @@ export const addEventToFuzzySearch = ev => {
};
export const addCachedMetadataToFuzzySearch = (profile: CachedMetadata) => {
// TODO add profiles from Cache
requestAnimationFrame(() => {
const existing = profileTimestamps.get(profile.pubkey);
if (existing) {

View File

@ -39,6 +39,12 @@ if (CONFIG.httpCache) {
};
}
System.ProfileLoader.Cache.hook(() => {
System.ProfileLoader.Cache.takeSnapshot().forEach(a => {
console.log("Profile: %O", a);
});
}, "profiles");
export async function fetchProfile(key: string) {
try {
throwIfOffline();

View File

@ -1,5 +1,6 @@
import { CachedMetadata } from ".";
import { fetchNip05Pubkey, FeedCache, LNURL, DexieTableLike } from "@snort/shared";
import { addCachedMetadataToFuzzySearch } from "@snort/app/src/Db/FuzzySearch";
export class UserProfileCache extends FeedCache<CachedMetadata> {
#zapperQueue: Array<{ pubkey: string; lnurl: string }> = [];
@ -21,6 +22,7 @@ export class UserProfileCache extends FeedCache<CachedMetadata> {
if (follows) {
await this.buffer(follows);
}
this.snapshot().forEach(p => addCachedMetadataToFuzzySearch(p));
}
async search(q: string): Promise<Array<CachedMetadata>> {