From 69d77c368e0cb3a3b65c21154e81ee3baec34c3d Mon Sep 17 00:00:00 2001
From: Lim Chee Aun <cheeaun@gmail.com>
Date: Thu, 29 Feb 2024 13:25:30 +0800
Subject: [PATCH] Experiment longer captions for no-content single-media post

---
 src/components/media.jsx  | 11 ++++++++++-
 src/components/status.jsx |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/components/media.jsx b/src/components/media.jsx
index 5b29dedb..abb343cb 100644
--- a/src/components/media.jsx
+++ b/src/components/media.jsx
@@ -54,6 +54,7 @@ const AltBadge = (props) => {
 };
 
 const MEDIA_CAPTION_LIMIT = 140;
+const MEDIA_CAPTION_LIMIT_LONGER = 280;
 export const isMediaCaptionLong = mem((caption) =>
   caption?.length
     ? caption.length > MEDIA_CAPTION_LIMIT ||
@@ -69,6 +70,7 @@ function Media({
   showOriginal,
   autoAnimate,
   showCaption,
+  allowLongerCaption,
   altIndex,
   onClick = () => {},
 }) {
@@ -198,8 +200,15 @@ function Media({
         };
 
   const longDesc = isMediaCaptionLong(description);
-  const showInlineDesc =
+  let showInlineDesc =
     !!showCaption && !showOriginal && !!description && !longDesc;
+  if (
+    allowLongerCaption &&
+    !showInlineDesc &&
+    description?.length <= MEDIA_CAPTION_LIMIT_LONGER
+  ) {
+    showInlineDesc = true;
+  }
   const Figure = !showInlineDesc
     ? Fragment
     : (props) => {
diff --git a/src/components/status.jsx b/src/components/status.jsx
index 7dbc0b13..5c8f6f36 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -1783,6 +1783,7 @@ function Status({
                       media={media}
                       autoAnimate={isSizeLarge}
                       showCaption={mediaAttachments.length === 1}
+                      allowLongerCaption={!content}
                       lang={language}
                       altIndex={
                         showMultipleMediaCaptions &&