mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-23 06:09:21 +01:00
Experiment longer captions for no-content single-media post
This commit is contained in:
parent
bb3621e424
commit
69d77c368e
2 changed files with 11 additions and 1 deletions
|
@ -54,6 +54,7 @@ const AltBadge = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const MEDIA_CAPTION_LIMIT = 140;
|
const MEDIA_CAPTION_LIMIT = 140;
|
||||||
|
const MEDIA_CAPTION_LIMIT_LONGER = 280;
|
||||||
export const isMediaCaptionLong = mem((caption) =>
|
export const isMediaCaptionLong = mem((caption) =>
|
||||||
caption?.length
|
caption?.length
|
||||||
? caption.length > MEDIA_CAPTION_LIMIT ||
|
? caption.length > MEDIA_CAPTION_LIMIT ||
|
||||||
|
@ -69,6 +70,7 @@ function Media({
|
||||||
showOriginal,
|
showOriginal,
|
||||||
autoAnimate,
|
autoAnimate,
|
||||||
showCaption,
|
showCaption,
|
||||||
|
allowLongerCaption,
|
||||||
altIndex,
|
altIndex,
|
||||||
onClick = () => {},
|
onClick = () => {},
|
||||||
}) {
|
}) {
|
||||||
|
@ -198,8 +200,15 @@ function Media({
|
||||||
};
|
};
|
||||||
|
|
||||||
const longDesc = isMediaCaptionLong(description);
|
const longDesc = isMediaCaptionLong(description);
|
||||||
const showInlineDesc =
|
let showInlineDesc =
|
||||||
!!showCaption && !showOriginal && !!description && !longDesc;
|
!!showCaption && !showOriginal && !!description && !longDesc;
|
||||||
|
if (
|
||||||
|
allowLongerCaption &&
|
||||||
|
!showInlineDesc &&
|
||||||
|
description?.length <= MEDIA_CAPTION_LIMIT_LONGER
|
||||||
|
) {
|
||||||
|
showInlineDesc = true;
|
||||||
|
}
|
||||||
const Figure = !showInlineDesc
|
const Figure = !showInlineDesc
|
||||||
? Fragment
|
? Fragment
|
||||||
: (props) => {
|
: (props) => {
|
||||||
|
|
|
@ -1783,6 +1783,7 @@ function Status({
|
||||||
media={media}
|
media={media}
|
||||||
autoAnimate={isSizeLarge}
|
autoAnimate={isSizeLarge}
|
||||||
showCaption={mediaAttachments.length === 1}
|
showCaption={mediaAttachments.length === 1}
|
||||||
|
allowLongerCaption={!content}
|
||||||
lang={language}
|
lang={language}
|
||||||
altIndex={
|
altIndex={
|
||||||
showMultipleMediaCaptions &&
|
showMultipleMediaCaptions &&
|
||||||
|
|
Loading…
Reference in a new issue