Auto register client plugins
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
import {PINS, asDecryptedEvent, readList} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {RepositoryCollection} from "./repositoryCollection.js"
|
||||
import type {ClientContext} from "./client.js"
|
||||
import type {RelayLists} from "./relayLists.js"
|
||||
import {RelayLists} from "./relayLists.js"
|
||||
import type {IClient} from "./client.js"
|
||||
|
||||
/**
|
||||
* NIP-51 pin lists (kind 10001), keyed by pubkey. Loaded via the outbox model
|
||||
* (the author's write relays), so it depends on the relay-list collection.
|
||||
*/
|
||||
export class PinLists extends RepositoryCollection<ReturnType<typeof readList>> {
|
||||
constructor(
|
||||
ctx: ClientContext,
|
||||
readonly relayLists: RelayLists,
|
||||
) {
|
||||
constructor(ctx: IClient) {
|
||||
super(ctx, {
|
||||
filters: [{kinds: [PINS]}],
|
||||
eventToItem: (event: TrustedEvent) => readList(asDecryptedEvent(event)),
|
||||
@@ -21,6 +18,6 @@ export class PinLists extends RepositoryCollection<ReturnType<typeof readList>>
|
||||
}
|
||||
|
||||
fetch(pubkey: string, relayHints: string[] = []) {
|
||||
return this.relayLists.makeOutboxLoader(PINS)(pubkey, relayHints)
|
||||
return this.ctx.use(RelayLists).makeOutboxLoader(PINS)(pubkey, relayHints)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user