Add Contacts page

This commit is contained in:
dtonon 2026-05-15 11:47:01 +01:00
parent 04ef78b8a5
commit d4982dff0c
5 changed files with 141 additions and 10 deletions

View file

@ -7,6 +7,7 @@ export type GroupMetadata = {
about?: string;
isPrivate: boolean;
isClosed: boolean;
admins: string[];
};
let group = $state<GroupMetadata | null>(null);
@ -21,18 +22,22 @@ export async function loadGroup() {
const pool = new SimplePool();
try {
const events = await pool.querySync([RELAY_URL], {
kinds: [39000],
kinds: [39000, 39001],
"#d": [GROUP_ID],
limit: 1,
});
const event = events[0];
const event = events.find((e) => e.kind === 39000);
if (!event) return;
// Admins live in the NIP-29 kind 39001 event as `p` tags.
const adminsEvent = events.find((e) => e.kind === 39001);
const admins =
adminsEvent?.tags.filter((t) => t[0] === "p").map((t) => t[1]) ?? [];
group = {
name: event.tags.find((t) => t[0] === "name")?.[1] ?? GROUP_ID,
picture: event.tags.find((t) => t[0] === "picture")?.[1],
about: event.tags.find((t) => t[0] === "about")?.[1],
isPrivate: event.tags.some((t) => t[0] === "private"),
isClosed: event.tags.some((t) => t[0] === "closed"),
admins,
};
} finally {
pool.close([RELAY_URL]);