mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-23 23:18:12 +02:00
Enable video playback in post previews for better visualization
Update `PreviewModal.tsx` to conditionally render either a video element with controls or an image based on the media type, resolving an issue where videos were not displayed in previews. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/nlpElis
This commit is contained in:
1 parent
942dd25d59
commit
68ed5d52d4
1 file changed
+27
-15
@@ -64,6 +64,30 @@ export function PreviewModal({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderMedia = (media: Media, className: string = "w-full h-auto") => {
|
||||||
|
const url = getMediaUrl(media);
|
||||||
|
|
||||||
|
if (media.type === 'video') {
|
||||||
|
return (
|
||||||
|
<video
|
||||||
|
src={url}
|
||||||
|
className={className}
|
||||||
|
controls
|
||||||
|
playsInline
|
||||||
|
data-testid="video-preview"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src={url}
|
||||||
|
alt={`Photo ${currentPhotoIndex + 1}`}
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const renderFacebookFeed = () => (
|
const renderFacebookFeed = () => (
|
||||||
<div className="bg-white rounded-lg overflow-hidden border border-gray-200 max-w-lg mx-auto">
|
<div className="bg-white rounded-lg overflow-hidden border border-gray-200 max-w-lg mx-auto">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -87,11 +111,7 @@ export function PreviewModal({
|
|||||||
{/* Media Carousel */}
|
{/* Media Carousel */}
|
||||||
{orderedMedia.length > 0 && (
|
{orderedMedia.length > 0 && (
|
||||||
<div className="relative bg-black">
|
<div className="relative bg-black">
|
||||||
<img
|
{renderMedia(orderedMedia[currentPhotoIndex], "w-full h-auto")}
|
||||||
src={getMediaUrl(orderedMedia[currentPhotoIndex])}
|
|
||||||
alt={`Photo ${currentPhotoIndex + 1}`}
|
|
||||||
className="w-full h-auto"
|
|
||||||
/>
|
|
||||||
{orderedMedia.length > 1 && (
|
{orderedMedia.length > 1 && (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
@@ -149,11 +169,7 @@ export function PreviewModal({
|
|||||||
{/* Media Carousel */}
|
{/* Media Carousel */}
|
||||||
{orderedMedia.length > 0 && (
|
{orderedMedia.length > 0 && (
|
||||||
<div className="relative bg-black aspect-square">
|
<div className="relative bg-black aspect-square">
|
||||||
<img
|
{renderMedia(orderedMedia[currentPhotoIndex], "w-full h-full object-cover")}
|
||||||
src={getMediaUrl(orderedMedia[currentPhotoIndex])}
|
|
||||||
alt={`Photo ${currentPhotoIndex + 1}`}
|
|
||||||
className="w-full h-full object-cover"
|
|
||||||
/>
|
|
||||||
{orderedMedia.length > 1 && (
|
{orderedMedia.length > 1 && (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
@@ -221,11 +237,7 @@ export function PreviewModal({
|
|||||||
{/* Media */}
|
{/* Media */}
|
||||||
{orderedMedia.length > 0 && (
|
{orderedMedia.length > 0 && (
|
||||||
<div className="relative h-full">
|
<div className="relative h-full">
|
||||||
<img
|
{renderMedia(orderedMedia[currentPhotoIndex], "w-full h-full object-cover")}
|
||||||
src={getMediaUrl(orderedMedia[currentPhotoIndex])}
|
|
||||||
alt={`Story ${currentPhotoIndex + 1}`}
|
|
||||||
className="w-full h-full object-cover"
|
|
||||||
/>
|
|
||||||
{orderedMedia.length > 1 && (
|
{orderedMedia.length > 1 && (
|
||||||
<>
|
<>
|
||||||
<div className="absolute top-3 left-3 right-3 flex gap-1">
|
<div className="absolute top-3 left-3 right-3 flex gap-1">
|
||||||
|
|||||||
Reference in new issue
Block a user