From 549300f20daad6b87fc76da5f5ab6891503a8e86 Mon Sep 17 00:00:00 2001 From: plebeius Date: Fri, 27 Feb 2026 14:42:46 +0800 Subject: [PATCH] feat: show file/image labels instead of link when requirePostLinkIsMedia is truthy --- public/translations/en/default.json | 1 + src/components/board-buttons/board-buttons.tsx | 7 +++++-- src/components/catalog-row/catalog-row.tsx | 6 ++++-- src/components/post-desktop/post-desktop.tsx | 4 +++- src/components/post-mobile/post-mobile.tsx | 4 +++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 22086ca9..fe7fdd33 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -174,6 +174,7 @@ "user_banned": "User was banned for this post", "replies": "replies", "links": "links", + "images": "images", "animated_gif": "Animated GIF", "pending": "Pending", "failed": "Failed", diff --git a/src/components/board-buttons/board-buttons.tsx b/src/components/board-buttons/board-buttons.tsx index b5bae65e..37472a1e 100644 --- a/src/components/board-buttons/board-buttons.tsx +++ b/src/components/board-buttons/board-buttons.tsx @@ -3,7 +3,7 @@ import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; import { useAccountComment, useComment, useSubscribe } from '@plebbit/plebbit-react-hooks'; import { isAllView, isCatalogView, isModView, isModQueueView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils'; import { usePostPageNumber } from '../../hooks/use-post-page-number'; -import { useDirectories } from '../../hooks/use-directories'; +import { useDirectories, useDirectoryByAddress } from '../../hooks/use-directories'; import { getBoardPath, isDirectoryBoard } from '../../lib/utils/route-utils'; import { useResolvedSubplebbitAddress } from '../../hooks/use-resolved-subplebbit-address'; import useCatalogFiltersStore from '../../stores/use-catalog-filters-store'; @@ -470,6 +470,8 @@ export const PostPageStats = () => { const { closed, pinned, replyCount } = post || {}; const linkCount = useCountLinksInReplies(post); + const directoryEntry = useDirectoryByAddress(subplebbitAddress); + const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; const isThreadView = isPostPageView(location.pathname, params); const pageNumber = usePostPageNumber({ @@ -485,7 +487,8 @@ export const PostPageStats = () => { {pinned && `${capitalize(t('sticky'))} / `} {closed && `${capitalize(t('closed'))} / `} - {displayReplyCount} / {linkCount?.toString()} + {displayReplyCount} /{' '} + {linkCount?.toString()} {isThreadView && ( <> {' '} diff --git a/src/components/catalog-row/catalog-row.tsx b/src/components/catalog-row/catalog-row.tsx index f3d6ae3e..2c8ae19f 100644 --- a/src/components/catalog-row/catalog-row.tsx +++ b/src/components/catalog-row/catalog-row.tsx @@ -128,6 +128,8 @@ const CatalogPost = memo( const isInAllView = isAllView(location.pathname); const isInSubscriptionsView = isSubscriptionsView(location.pathname, params); const directories = useDirectories(); + const directoryEntry = directories?.find((c) => c.address === subplebbitAddress); + const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; const boardPath = subplebbitAddress ? getBoardPath(subplebbitAddress, directories) : ''; const postMenuProps = useMemo(() => selectPostMenuProps(post), [post]); @@ -257,12 +259,12 @@ const CatalogPost = memo( ) : ( threadIcons )} -
+
R: {replyCount || '0'} {linkCount > 0 && ( {' '} - / L: {linkCount} + / {requirePostLinkIsMedia ? 'I' : 'L'}: {linkCount} )} diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 8d81ecd6..7c9fffd5 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -556,6 +556,8 @@ const PostMedia = ({ const [showThumbnail, setShowThumbnail] = useState(true); const mediaDimensions = getMediaDimensions(commentMediaInfo); + const directoryEntry = directories?.find((c) => c.address === subplebbitAddress); + const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; const boardPath = getBoardPath(subplebbitAddress, directories); const displayBoardPath = boardPath !== subplebbitAddress @@ -572,7 +574,7 @@ const PostMedia = ({ {t('board')}: {displayBoardPath}{' '} )} - {t('link')}:{' '} + {requirePostLinkIsMedia ? t('file') : t('link')}:{' '} {spoiler ? capitalize(t('spoiler')) : url && url.length > 30 ? url.slice(0, 30) + '...' : url} {' '} diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index a49d1f25..718ea344 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -537,6 +537,8 @@ const PostMobile = ({ const isInPendingPostView = isPendingPostView(location.pathname, params); const isInPostView = isPostPageView(location.pathname, params); const directories = useDirectories(); + const directoryEntry = directories?.find((c) => c.address === subplebbitAddress); + const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; const boardPath = subplebbitAddress ? getBoardPath(subplebbitAddress, directories) : undefined; const linksCount = useCountLinksInReplies(post); const shouldFetchReplies = showReplies && !isModQueue; @@ -695,7 +697,7 @@ const PostMobile = ({
{replyCount > 0 && `${replyCount} Replies`} - {linksCount > 0 && ` / ${linksCount} Links`} + {linksCount > 0 && ` / ${linksCount} ${requirePostLinkIsMedia ? 'Images' : 'Links'}`} {isModQueue ? (