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

@ -59,10 +59,6 @@
>
More
</p>
<a
href="/settings"
class="block py-1 text-neutral-500 hover:text-neutral-900">Settings</a
>
<a
href="/contacts"
class="block py-1 text-neutral-500 hover:text-neutral-900">Contacts</a

View file

@ -22,7 +22,4 @@
{/if}
<span class="text-[1.7rem] font-medium text-neutral-900">{name}</span>
</div>
<button class="text-sm text-neutral-500 hover:text-neutral-900"
>Create your own community</button
>
</header>

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]);

View file

@ -12,6 +12,8 @@ export type ProfileEntry = {
nip05?: string;
picture?: string;
about?: string;
website?: string;
lud16?: string;
fetchedAt: number;
};
@ -56,6 +58,8 @@ function parseProfileEvent(evt: Event): ProfileEntry | null {
nip05?: string;
picture?: string;
about?: string;
website?: string;
lud16?: string;
} = {};
try {
md = JSON.parse(evt.content);
@ -70,6 +74,8 @@ function parseProfileEvent(evt: Event): ProfileEntry | null {
nip05: md.nip05,
picture: md.picture,
about: md.about,
website: md.website,
lud16: md.lud16,
fetchedAt: evt.created_at,
};
}
@ -315,6 +321,8 @@ export function ingestNostrUser(user: NostrUser) {
nip05: md.nip05,
picture: md.picture ?? user.image,
about: md.about,
website: md.website,
lud16: md.lud16,
fetchedAt: user.lastUpdated || 0,
};
upsertProfile(entry);