refactor: tweak profile loader

This commit is contained in:
2024-06-25 16:14:53 +01:00
parent 1a405f7796
commit bdc94cec8b
5 changed files with 52 additions and 5 deletions

View File

@ -79,6 +79,9 @@ export abstract class BackgroundLoader<T extends { loaded: number; created: numb
resolve(existing);
this.UntrackKeys(key);
this.cache.off("change", handler);
} else {
// should never happen
reject(new Error("Not found"));
}
}
};

View File

@ -1,6 +1,6 @@
import { unixNowMs } from "@snort/shared";
import { EventKind, TaggedNostrEvent, RequestBuilder } from ".";
import { MetadataRelays, ProfileCacheExpire } from "./const";
import { ProfileCacheExpire } from "./const";
import { mapEventToProfile, CachedMetadata } from "./cache";
import { BackgroundLoader } from "./background-loader";
@ -19,7 +19,7 @@ export class ProfileLoaderService extends BackgroundLoader<CachedMetadata> {
override buildSub(missing: string[]): RequestBuilder {
const sub = new RequestBuilder(`profiles`);
sub.withFilter().kinds([EventKind.SetMetadata]).authors(missing).relay(MetadataRelays);
sub.withFilter().kinds([EventKind.SetMetadata]).authors(missing);
return sub;
}
}