refactor: remove muteList as a field
This commit is contained in:
parent
ddc84bf47a
commit
c87db6d1f8
|
@ -5,12 +5,10 @@ import { getTagSet } from '@/tags.ts';
|
|||
export class UserStore implements NStore {
|
||||
private store: NStore;
|
||||
private pubkey: string;
|
||||
private muteList: Promise<DittoEvent | undefined>;
|
||||
|
||||
constructor(pubkey: string, store: NStore) {
|
||||
this.pubkey = pubkey;
|
||||
this.store = store;
|
||||
this.muteList = this.getMuteList();
|
||||
}
|
||||
|
||||
async event(event: NostrEvent, opts?: { signal?: AbortSignal }): Promise<void> {
|
||||
|
@ -24,7 +22,7 @@ export class UserStore implements NStore {
|
|||
async query(filters: NostrFilter[], opts: { signal?: AbortSignal; limit?: number } = {}): Promise<DittoEvent[]> {
|
||||
const allEvents = await this.store.query(filters, opts);
|
||||
|
||||
const mutedPubkeysEvent = await this.muteList;
|
||||
const mutedPubkeysEvent = await this.getMuteList();
|
||||
if (!mutedPubkeysEvent) {
|
||||
return allEvents;
|
||||
}
|
||||
|
@ -36,10 +34,7 @@ export class UserStore implements NStore {
|
|||
}
|
||||
|
||||
private async getMuteList(): Promise<DittoEvent | undefined> {
|
||||
const [muteList] = await this.query([{ authors: [this.pubkey], kinds: [10000], limit: 1 }], {
|
||||
signal: AbortSignal.timeout(5000),
|
||||
limit: 1,
|
||||
});
|
||||
const [muteList] = await this.store.query([{ authors: [this.pubkey], kinds: [10000], limit: 1 }]);
|
||||
return muteList;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue