spa(task 12): replies-loader für kind:1 mit a-tag-filter
Fügt `loadReplies(dtag)` an loaders.ts an. Filter `#a` auf das addressable-Event-Format "30023:<pubkey>:<dtag>" findet alle kind:1 Replies auf den Post. Sortiert aufsteigend (älteste zuerst). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
09f2ce8b49
commit
bab2895848
|
|
@ -121,3 +121,26 @@ export async function loadProfile(): Promise<Profile | null> {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Post-Adresse im `a`-Tag-Format: "30023:<pubkey>:<dtag>" */
|
||||
function eventAddress(pubkey: string, dtag: string): string {
|
||||
return `30023:${pubkey}:${dtag}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle kind:1-Replies auf einen Post, chronologisch aufsteigend (älteste zuerst).
|
||||
* Streamt via onEvent, wenn angegeben.
|
||||
*/
|
||||
export async function loadReplies(
|
||||
dtag: string,
|
||||
onEvent?: (ev: NostrEvent) => void
|
||||
): Promise<NostrEvent[]> {
|
||||
const relays = get(readRelays);
|
||||
const address = eventAddress(AUTHOR_PUBKEY_HEX, dtag);
|
||||
const events = await collectEvents(
|
||||
relays,
|
||||
{ kinds: [1], '#a': [address], limit: 500 },
|
||||
{ onEvent }
|
||||
);
|
||||
return events.sort((a, b) => a.created_at - b.created_at);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue