From 0a52944a07d0dff523f4e35704e4bd235e284e73 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 8 Apr 2024 19:34:09 +0200 Subject: [PATCH] feat(media): add support for audio links --- src/components/media/media.tsx | 29 ++++++++++++++++++++--------- src/components/post/post.tsx | 4 ++-- src/lib/utils/media-utils.ts | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/components/media/media.tsx b/src/components/media/media.tsx index cdffeb1a..79fbb8fc 100644 --- a/src/components/media/media.tsx +++ b/src/components/media/media.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import styles from './media.module.css'; import { CommentMediaInfo } from '../../lib/utils/media-utils'; import useFetchGifFirstFrame from '../../hooks/use-fetch-gif-first-frame'; @@ -34,7 +34,7 @@ const ThumbnailSmall = ({ style, children, thumbnailSmallPadding }: ThumbnailPro ); -const Thumbnail = ({ commentMediaInfo, isMobile, isReply, linkHeight, linkWidth }: MediaProps) => { +const Thumbnail = ({ commentMediaInfo, isMobile, isReply, linkHeight, linkWidth, setShowThumbnail }: MediaProps) => { let displayWidth, displayHeight; const maxThumbnailSize = isMobile || isReply ? 125 : 250; if (linkWidth && linkHeight) { @@ -46,19 +46,30 @@ const Thumbnail = ({ commentMediaInfo, isMobile, isReply, linkHeight, linkWidth displayHeight = `${maxThumbnailSize}px`; } + if (commentMediaInfo?.type === 'audio') { + displayWidth = '250px'; + displayHeight = '75px'; + } + let mediaComponent: React.ReactNode = null; const iframeThumbnail = commentMediaInfo?.patternThumbnailUrl || commentMediaInfo?.thumbnail; const gifFrameUrl = useFetchGifFirstFrame(commentMediaInfo?.type === 'gif' ? commentMediaInfo.url : undefined); if (commentMediaInfo?.type === 'image') { - mediaComponent = ; + mediaComponent = setShowThumbnail(false)} />; } else if (commentMediaInfo?.type === 'video') { - mediaComponent = commentMediaInfo.thumbnail ? :