From e76ed044f8c47891e00610ba2dc34f26297cf974 Mon Sep 17 00:00:00 2001 From: silberengel Date: Sun, 24 Aug 2025 08:32:58 +0200 Subject: [PATCH] fixed reactive card display --- src/app.css | 9 + src/lib/components/EventDetails.svelte | 3 + src/lib/components/cards/ProfileHeader.svelte | 44 +- src/routes/events/+page.svelte | 402 ++++++++++++------ 4 files changed, 304 insertions(+), 154 deletions(-) diff --git a/src/app.css b/src/app.css index 0d1928c..aa88636 100644 --- a/src/app.css +++ b/src/app.css @@ -98,6 +98,15 @@ @apply text-gray-900 dark:text-gray-100; } + /* Responsive card styles */ + .responsive-card { + @apply w-full min-w-0 overflow-hidden; + } + + .responsive-card-content { + @apply break-words overflow-hidden; + } + h1.h-leather { @apply text-4xl font-bold; } diff --git a/src/lib/components/EventDetails.svelte b/src/lib/components/EventDetails.svelte index 12d830c..f4530b2 100644 --- a/src/lib/components/EventDetails.svelte +++ b/src/lib/components/EventDetails.svelte @@ -26,9 +26,11 @@ const { event, profile = null, + communityStatusMap = {}, } = $props<{ event: NDKEvent; profile?: UserProfile | null; + communityStatusMap?: Record; }>(); const ndk = getNdkContext(); @@ -378,6 +380,7 @@ {/if} diff --git a/src/lib/components/cards/ProfileHeader.svelte b/src/lib/components/cards/ProfileHeader.svelte index a1fc210..1eeb89f 100644 --- a/src/lib/components/cards/ProfileHeader.svelte +++ b/src/lib/components/cards/ProfileHeader.svelte @@ -55,26 +55,32 @@ $effect(() => { if (event?.pubkey) { - // First check if we have cached profileData with user list information - const cachedProfileData = (event as any).profileData; - console.log(`[ProfileHeader] Checking user list status for ${event.pubkey}, cached profileData:`, cachedProfileData); - - if (cachedProfileData && typeof cachedProfileData.isInUserLists === 'boolean') { - isInUserLists = cachedProfileData.isInUserLists; - console.log(`[ProfileHeader] Using cached user list status for ${event.pubkey}: ${isInUserLists}`); + // First check if we have user list information in the profile prop + if (profile && typeof profile.isInUserLists === 'boolean') { + isInUserLists = profile.isInUserLists; + console.log(`[ProfileHeader] Using profile prop user list status for ${event.pubkey}: ${isInUserLists}`); } else { - console.log(`[ProfileHeader] No cached user list data, fetching for ${event.pubkey}`); - // Fallback to fetching user lists - fetchCurrentUserLists() - .then((userLists) => { - console.log(`[ProfileHeader] Fetched ${userLists.length} user lists for ${event.pubkey}`); - isInUserLists = isPubkeyInUserLists(event.pubkey, userLists); - console.log(`[ProfileHeader] Final user list status for ${event.pubkey}: ${isInUserLists}`); - }) - .catch((error) => { - console.error(`[ProfileHeader] Error fetching user lists for ${event.pubkey}:`, error); - isInUserLists = false; - }); + // Then check if we have cached profileData with user list information + const cachedProfileData = (event as any).profileData; + console.log(`[ProfileHeader] Checking user list status for ${event.pubkey}, cached profileData:`, cachedProfileData); + + if (cachedProfileData && typeof cachedProfileData.isInUserLists === 'boolean') { + isInUserLists = cachedProfileData.isInUserLists; + console.log(`[ProfileHeader] Using cached user list status for ${event.pubkey}: ${isInUserLists}`); + } else { + console.log(`[ProfileHeader] No cached user list data, fetching for ${event.pubkey}`); + // Fallback to fetching user lists + fetchCurrentUserLists() + .then((userLists) => { + console.log(`[ProfileHeader] Fetched ${userLists.length} user lists for ${event.pubkey}`); + isInUserLists = isPubkeyInUserLists(event.pubkey, userLists); + console.log(`[ProfileHeader] Final user list status for ${event.pubkey}: ${isInUserLists}`); + }) + .catch((error) => { + console.error(`[ProfileHeader] Error fetching user lists for ${event.pubkey}:`, error); + isInUserLists = false; + }); + } } // Check community status - use cached data if available diff --git a/src/routes/events/+page.svelte b/src/routes/events/+page.svelte index 5676f1e..bec76db 100644 --- a/src/routes/events/+page.svelte +++ b/src/routes/events/+page.svelte @@ -91,10 +91,17 @@ try { const parsedProfile = parseProfileContent(newEvent); if (parsedProfile) { - profile = parsedProfile; - - // If the event doesn't have user list information, fetch it - if (typeof parsedProfile.isInUserLists !== "boolean") { + // Check if we already have user list information from the search results + const existingProfileData = (newEvent as any).profileData; + if (existingProfileData && typeof existingProfileData.isInUserLists === "boolean") { + // Use the existing user list status from search results + profile = { ...parsedProfile, isInUserLists: existingProfileData.isInUserLists } as any; + console.log(`[Events Page] Using existing user list status for ${newEvent.pubkey}: ${existingProfileData.isInUserLists}`); + } else { + // Set initial profile and fetch user list information + profile = parsedProfile; + + // Fetch user list information fetchCurrentUserLists(undefined, ndk) .then((userLists) => { const isInLists = isPubkeyInUserLists( @@ -103,11 +110,12 @@ ); // Update the profile with user list information profile = { ...parsedProfile, isInUserLists: isInLists } as any; - // Also update the event's profileData + // Also update the event's profileData for consistency (newEvent as any).profileData = { ...parsedProfile, isInUserLists: isInLists, }; + console.log(`[Events Page] Updated user list status for ${newEvent.pubkey}: ${isInLists}`); }) .catch(() => { profile = { ...parsedProfile, isInUserLists: false } as any; @@ -115,6 +123,7 @@ ...parsedProfile, isInUserLists: false, }; + console.log(`[Events Page] Set default user list status for ${newEvent.pubkey}: false`); }); } } else { @@ -136,17 +145,16 @@ if (newEvent.pubkey) { cacheProfileForPubkey(newEvent.pubkey); - // Update profile data with user list information - updateProfileDataWithUserLists([newEvent]); - - // Also check community status for the individual event + // Also check community status for the individual event if not already cached if (!communityStatus[newEvent.pubkey]) { checkCommunity(newEvent.pubkey) .then((status) => { communityStatus = { ...communityStatus, [newEvent.pubkey]: status }; + console.log(`[Events Page] Updated community status for ${newEvent.pubkey}: ${status}`); }) .catch(() => { communityStatus = { ...communityStatus, [newEvent.pubkey]: false }; + console.log(`[Events Page] Set default community status for ${newEvent.pubkey}: false`); }); } } @@ -501,15 +509,16 @@
-
+
Events
@@ -588,7 +597,7 @@ ? "lg:block hidden" : "block"} > - + {#if searchType === "n"} Search Results for name: "{searchTerm && searchTerm.length > 50 @@ -610,64 +619,95 @@ })()}" ({searchResults.length} events) {/if} -
+
{#each searchResults as result, index} {@const profileData = (result as any).profileData || parseProfileContent(result)}