Add labels to the listing

This commit is contained in:
dtonon 2026-04-09 17:13:20 +01:00
parent b5b2f97d35
commit ce03876fed
3 changed files with 11 additions and 0 deletions

View file

@ -10,6 +10,7 @@
export type ThreadRow = { export type ThreadRow = {
id: string; id: string;
title: string; title: string;
labels: string[];
author: Author; author: Author;
replyCount: number; replyCount: number;
repliers: Author[]; repliers: Author[];
@ -54,6 +55,13 @@
{/each} {/each}
</div> </div>
{/if} {/if}
{#if thread.labels.length > 0}
<div class="ml-auto flex flex-wrap items-center justify-end gap-1">
{#each thread.labels as l}
<Tag label={l} />
{/each}
</div>
{/if}
</div> </div>
</div> </div>

View file

@ -5,6 +5,7 @@ import { RELAY_URL, GROUP_ID } from "$lib/config";
export type ThreadData = { export type ThreadData = {
id: string; id: string;
title: string; title: string;
labels: string[];
authorPubkey: string; authorPubkey: string;
createdAt: number; createdAt: number;
replyCount: number; replyCount: number;
@ -42,6 +43,7 @@ export async function loadThreads() {
threads = events.map((e) => ({ threads = events.map((e) => ({
id: e.id, id: e.id,
title: e.tags.find((t) => t[0] === "title")?.[1] ?? "(untitled)", title: e.tags.find((t) => t[0] === "title")?.[1] ?? "(untitled)",
labels: e.tags.filter((t) => t[0] === "t" && t[1]).map((t) => t[1]),
authorPubkey: e.pubkey, authorPubkey: e.pubkey,
createdAt: e.created_at, createdAt: e.created_at,
replyCount: 0, replyCount: 0,

View file

@ -49,6 +49,7 @@
return { return {
id: t.id, id: t.id,
title: t.title, title: t.title,
labels: t.labels,
author: resolveAuthor(t.authorPubkey, profiles), author: resolveAuthor(t.authorPubkey, profiles),
replyCount: t.replyCount, replyCount: t.replyCount,
repliers: t.replierPubkeys.map((pk) => resolveAuthor(pk, profiles)), repliers: t.replierPubkeys.map((pk) => resolveAuthor(pk, profiles)),