From 631285fed2ea647ee42df82b4eb463a54eab2a17 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 11 Feb 2026 11:53:18 +0100 Subject: [PATCH] bug-fixes --- public/healthz.json | 4 +- .../profile/EditProfileEventsPanel.svelte | 60 +++++++++++++++++-- .../components/write/CreateEventForm.svelte | 7 ++- 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/public/healthz.json b/public/healthz.json index 04d0f5e..d7404bc 100644 --- a/public/healthz.json +++ b/public/healthz.json @@ -2,7 +2,7 @@ "status": "ok", "service": "aitherboard", "version": "0.3.0", - "buildTime": "2026-02-11T10:31:42.382Z", + "buildTime": "2026-02-11T10:52:47.456Z", "gitCommit": "unknown", - "timestamp": 1770805902382 + "timestamp": 1770807167456 } \ No newline at end of file diff --git a/src/lib/components/profile/EditProfileEventsPanel.svelte b/src/lib/components/profile/EditProfileEventsPanel.svelte index 509efc2..779a6d3 100644 --- a/src/lib/components/profile/EditProfileEventsPanel.svelte +++ b/src/lib/components/profile/EditProfileEventsPanel.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { nostrClient } from '../../services/nostr/nostr-client.js'; import { relayManager } from '../../services/nostr/relay-manager.js'; - import { isParameterizedReplaceableKind } from '../../types/kind-lookup.js'; + import { isParameterizedReplaceableKind, isReplaceableKind } from '../../types/kind-lookup.js'; import type { NostrEvent } from '../../types/nostr.js'; interface Props { @@ -48,9 +48,61 @@ loadingKinds = new Set(); loadedKinds = new Set(); - // Load events for all kinds in parallel - const loadPromises = PROFILE_EVENT_KINDS.map(({ kind }) => loadEventForKind(kind)); - await Promise.all(loadPromises); + // Separate replaceable kinds from parameterized replaceable kinds + const replaceableKinds = PROFILE_EVENT_KINDS + .map(({ kind }) => kind) + .filter(isReplaceableKind); + + const parameterizedKinds = PROFILE_EVENT_KINDS + .map(({ kind }) => kind) + .filter(isParameterizedReplaceableKind); + + // Mark all kinds as loading + const allKinds = [...replaceableKinds, ...parameterizedKinds]; + loadingKinds = new Set(allKinds); + + try { + const relays = relayManager.getProfileReadRelays(); + + // Single fetch for all replaceable kinds + if (replaceableKinds.length > 0) { + const events = await nostrClient.fetchEvents( + [{ kinds: replaceableKinds, authors: [pubkey], limit: replaceableKinds.length }], + relays, + { useCache: true, cacheResults: true } + ); + + // Group events by kind and get the newest for each kind + const eventsByKind = new Map(); + for (const event of events) { + if (!eventsByKind.has(event.kind)) { + eventsByKind.set(event.kind, []); + } + eventsByKind.get(event.kind)!.push(event); + } + + // Get newest event for each kind + const newMap = new Map(eventMap); + for (const kind of replaceableKinds) { + const kindEvents = eventsByKind.get(kind) || []; + if (kindEvents.length > 0) { + const newest = kindEvents.sort((a, b) => b.created_at - a.created_at)[0]; + newMap.set(kind, newest); + } + } + eventMap = newMap; + } + + // Load parameterized replaceable kinds separately (they need d-tag handling) + const parameterizedPromises = parameterizedKinds.map(kind => loadEventForKind(kind)); + await Promise.all(parameterizedPromises); + } catch (error) { + console.error('Error loading profile events:', error); + } finally { + // Mark all kinds as loaded + loadedKinds = new Set(allKinds); + loadingKinds = new Set(); + } } async function loadEventForKind(kind: number) { diff --git a/src/lib/components/write/CreateEventForm.svelte b/src/lib/components/write/CreateEventForm.svelte index 43e215c..0b11aff 100644 --- a/src/lib/components/write/CreateEventForm.svelte +++ b/src/lib/components/write/CreateEventForm.svelte @@ -13,7 +13,7 @@ import AdvancedEditor from './AdvancedEditor.svelte'; import { shouldIncludeClientTag } from '../../services/client-tag-preference.js'; import { goto } from '$app/navigation'; - import { KIND } from '../../types/kind-lookup.js'; + import { KIND, KIND_LOOKUP } from '../../types/kind-lookup.js'; import { getKindMetadata, getWritableKinds } from '../../types/kind-metadata.js'; import type { NostrEvent } from '../../types/nostr.js'; import { autoExtractTags, ensureDTagForParameterizedReplaceable } from '../../services/auto-tagging.js'; @@ -527,6 +527,11 @@ {#each SUPPORTED_KINDS as kind} {/each} + {#if selectedKind !== -1 && !SUPPORTED_KINDS.find(k => k.value === selectedKind)} + {@const kindInfo = getKindMetadata(selectedKind)} + {@const kindDescription = kindInfo?.description || KIND_LOOKUP[selectedKind]?.description || 'Unknown'} + + {/if} {#if isUnknownKind}