diff --git a/app/src/lib/components/ReplyItem.svelte b/app/src/lib/components/ReplyItem.svelte index 63d746f..c94a5df 100644 --- a/app/src/lib/components/ReplyItem.svelte +++ b/app/src/lib/components/ReplyItem.svelte @@ -1,5 +1,7 @@
  • -
    - {authorNpub} - · - {date} +
    + {#if profile?.picture} + {displayName} + {:else} + + {/if} +
    + {displayName} + {date} +
    {event.content}
  • @@ -25,20 +45,43 @@ padding: 0.8rem 0; border-bottom: 1px solid var(--border); } + .header { + display: flex; + gap: 0.6rem; + align-items: center; + margin-bottom: 0.4rem; + } + .avatar { + flex: 0 0 32px; + width: 32px; + height: 32px; + border-radius: 50%; + object-fit: cover; + background: var(--code-bg); + } + .avatar-placeholder { + display: block; + } .meta { font-size: 0.85rem; color: var(--muted); - margin-bottom: 0.3rem; + display: flex; + flex-direction: column; + line-height: 1.3; } - .author { - font-family: monospace; - } - .sep { - margin: 0 0.4rem; - opacity: 0.5; + .name { + color: var(--fg); + font-weight: 500; + word-break: break-word; } .content { white-space: pre-wrap; word-wrap: break-word; + margin-left: calc(32px + 0.6rem); + } + @media (max-width: 479px) { + .content { + margin-left: 0; + } } diff --git a/app/src/lib/nostr/loaders.ts b/app/src/lib/nostr/loaders.ts index 19cbb67..1fc64d0 100644 --- a/app/src/lib/nostr/loaders.ts +++ b/app/src/lib/nostr/loaders.ts @@ -103,12 +103,16 @@ export async function loadPost(dtag: string): Promise { ); } -/** Profil-Event kind:0 (neueste Version) */ -export async function loadProfile(): Promise { +/** + * Profil-Event kind:0 (neueste Version). + * Default: Autoren-Pubkey der SPA. Optional: beliebiger Pubkey für + * die Anzeige fremder Kommentar-Autoren. + */ +export async function loadProfile(pubkey: string = AUTHOR_PUBKEY_HEX): Promise { const relays = get(readRelays); const events = await collectEvents(relays, { kinds: [0], - authors: [AUTHOR_PUBKEY_HEX], + authors: [pubkey], limit: 1 }); if (events.length === 0) return null; diff --git a/app/src/lib/nostr/profileCache.ts b/app/src/lib/nostr/profileCache.ts new file mode 100644 index 0000000..dfb8d87 --- /dev/null +++ b/app/src/lib/nostr/profileCache.ts @@ -0,0 +1,17 @@ +import type { Profile } from './loaders'; +import { loadProfile } from './loaders'; + +/** + * Sessionsweiter Cache für kind:0-Profile. + * Jeder Pubkey wird maximal einmal angefragt; mehrfache parallele + * Aufrufe teilen sich dieselbe Promise. + */ +const cache = new Map>(); + +export function getProfile(pubkey: string): Promise { + const existing = cache.get(pubkey); + if (existing) return existing; + const pending = loadProfile(pubkey); + cache.set(pubkey, pending); + return pending; +} diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 13e33dd..f01e49a 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -1,7 +1,9 @@