From 5c15a34a19085ca9ad4d4880a77d632732acb746 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Sat, 18 Jul 2026 10:40:16 -0500 Subject: [PATCH] fix: resolve media file_ids for stream overlay and make news cards clickable --- src/components/media/StreamOverlays.tsx | 46 ++++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/components/media/StreamOverlays.tsx b/src/components/media/StreamOverlays.tsx index b6f82c1..dc83c6d 100644 --- a/src/components/media/StreamOverlays.tsx +++ b/src/components/media/StreamOverlays.tsx @@ -44,7 +44,27 @@ export const StreamOverlays = () => { [Query.limit(10), Query.orderDesc('$createdAt'), Query.equal('estado', 'Publicado')] ); - setRotatingContent(res.documents); + const posts = res.documents; + const mediaIds = posts.map(p => p.imagen_destacada_id).filter(id => id && typeof id === 'string'); + if (mediaIds.length > 0) { + try { + const mediaRes = await databases.listDocuments( + APPWRITE_ALMEIRA_CONFIG.databaseId, + 'media', + [Query.equal('$id', mediaIds)] + ); + const mediaMap = new Map(mediaRes.documents.map(m => [m.$id, m])); + posts.forEach(p => { + if (p.imagen_destacada_id && typeof p.imagen_destacada_id === 'string' && mediaMap.has(p.imagen_destacada_id)) { + p.resolved_media = mediaMap.get(p.imagen_destacada_id); + } + }); + } catch(e) { + console.error("Error resolving media for overlays:", e); + } + } + + setRotatingContent(posts); } catch (error) { console.error('Error fetching content for overlays:', error); } @@ -130,17 +150,25 @@ export const StreamOverlays = () => { {/* SIDE CONTENT CAROUSEL (BOTTOM LEFT ABOVE TICKER) */}
{activeItem && ( -
+ { + // If they click, we could theoretically stop rotation or close player, but just navigating is fine + }} + >
{(() => { - const mediaId = typeof activeItem.imagen_destacada_id === 'object' - ? activeItem.imagen_destacada_id?.$id - : activeItem.imagen_destacada_id; + let mediaObj = activeItem.resolved_media; + if (!mediaObj && typeof activeItem.imagen_destacada_id === 'object') { + mediaObj = activeItem.imagen_destacada_id; + } - if (mediaId) { + if (mediaObj && mediaObj.file_id) { + const bucketId = mediaObj.bucket_id || APPWRITE_ALMEIRA_CONFIG.mediaBucketId; return ( {activeItem.titulo} @@ -153,12 +181,12 @@ export const StreamOverlays = () => { ); })()}
-

+

{activeItem.titulo}

-
+ )}