fix(posts): Board link in multiboard views (/all/, /subs/, /mod/)

This commit is contained in:
plebeius
2026-02-22 15:02:31 +08:00
parent 71fdbef1ea
commit f521bdbe33
2 changed files with 43 additions and 6 deletions
+31 -3
View File
@@ -9,7 +9,7 @@ import { CommentMediaInfo, getDisplayMediaInfoType, getHasThumbnail, getMediaDim
import { hashStringToColor, getTextColorForBackground } from '../../lib/utils/post-utils';
import { getFormattedDate, getFormattedTimeAgo } from '../../lib/utils/time-utils';
import { isValidURL } from '../../lib/utils/url-utils';
import { isAllView, isModQueueView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { isAllView, isModQueueView, isModView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { formatUserIDForDisplay } from '../../lib/utils/string-utils';
import useModQueueStore from '../../stores/use-mod-queue-store';
import { useDirectories } from '../../hooks/use-directories';
@@ -497,6 +497,7 @@ interface PostMediaProps {
subplebbitAddress: string;
isInAllView: boolean;
isInSubscriptionsView: boolean;
isInModView: boolean;
}
const PostMedia = ({
@@ -511,6 +512,7 @@ const PostMedia = ({
subplebbitAddress,
isInAllView,
isInSubscriptionsView,
isInModView,
}: PostMediaProps) => {
const { t } = useTranslation();
const { url } = commentMediaInfo || {};
@@ -529,13 +531,19 @@ const PostMedia = ({
const mediaDimensions = getMediaDimensions(commentMediaInfo);
const boardPath = getBoardPath(subplebbitAddress, directories);
const displayBoardPath =
boardPath !== subplebbitAddress
? boardPath
: subplebbitAddress.endsWith('.eth') || subplebbitAddress.endsWith('.sol')
? subplebbitAddress
: Plebbit.getShortAddress({ address: subplebbitAddress });
return (
<div className={styles.file}>
<div className={styles.fileText}>
{subplebbitAddress && (isInAllView || isInSubscriptionsView) && boardPath && !parentCid && (
{subplebbitAddress && (isInAllView || isInSubscriptionsView || isInModView) && boardPath && !parentCid && (
<>
{t('board')}: <Link to={`/${boardPath}`}>{boardPath}</Link>{' '}
{t('board')}: <Link to={`/${boardPath}`}>{displayBoardPath}</Link>{' '}
</>
)}
{t('link')}:{' '}
@@ -613,6 +621,7 @@ const Reply = ({
const isInAllView = isAllView(location.pathname);
const params = useParams();
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
const isInModView = isModView(location.pathname);
const commentMediaInfo = useCommentMediaInfo(link, thumbnailUrl, linkWidth, linkHeight);
const hasThumbnail = getHasThumbnail(commentMediaInfo, link);
@@ -643,6 +652,7 @@ const Reply = ({
subplebbitAddress={subplebbitAddress}
isInAllView={isInAllView}
isInSubscriptionsView={isInSubscriptionsView}
isInModView={isInModView}
/>
)}
{!hidden && (!(removed || deleted) || ((removed || deleted) && reason)) && <CommentContent comment={post} />}
@@ -673,8 +683,18 @@ const PostDesktop = ({
const isInPostPageView = isPostPageView(location.pathname, params);
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
const isInModView = isModView(location.pathname);
const isMultiboardView = isInAllView || isInSubscriptionsView || isInModView;
const directories = useDirectories();
const boardPath = subplebbitAddress ? getBoardPath(subplebbitAddress, directories) : undefined;
const displayBoardPath =
boardPath && subplebbitAddress
? boardPath !== subplebbitAddress
? boardPath
: subplebbitAddress.endsWith('.eth') || subplebbitAddress.endsWith('.sol')
? subplebbitAddress
: Plebbit.getShortAddress({ address: subplebbitAddress })
: undefined;
const { hidden, unhide, hide } = useHide({ cid });
const isHidden = hidden && !isInPostPageView;
@@ -809,6 +829,13 @@ const PostDesktop = ({
className={`${styles.opContainer} ${shouldShowSnow() && hasThumbnail ? styles.xmasHatWrapper : ''}`}
>
{shouldShowSnow() && hasThumbnail && <img src='assets/xmashat.gif' className={styles.xmasHat} alt='' />}
{!link && !parentCid && subplebbitAddress && isMultiboardView && boardPath && (
<div className={styles.file}>
<div className={styles.fileText}>
{t('board')}: <Link to={`/${boardPath}`}>{displayBoardPath}</Link>
</div>
</div>
)}
{link && !isHidden && !(deleted || removed) && isValidURL(link) && (
<PostMedia
commentMediaInfo={commentMediaInfo}
@@ -822,6 +849,7 @@ const PostDesktop = ({
subplebbitAddress={subplebbitAddress}
isInAllView={isInAllView}
isInSubscriptionsView={isInSubscriptionsView}
isInModView={isInModView}
/>
)}
<PostInfo
+12 -3
View File
@@ -9,7 +9,7 @@ import { shouldShowSnow } from '../../lib/snow';
import { getHasThumbnail } from '../../lib/utils/media-utils';
import { getTextColorForBackground, hashStringToColor } from '../../lib/utils/post-utils';
import { getFormattedDate, getFormattedTimeAgo } from '../../lib/utils/time-utils';
import { isAllView, isModQueueView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { isAllView, isModQueueView, isModView, isPendingPostView, isPostPageView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { formatUserIDForDisplay } from '../../lib/utils/string-utils';
import useModQueueStore from '../../stores/use-mod-queue-store';
import { useDirectories } from '../../hooks/use-directories';
@@ -59,6 +59,14 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos
const { author, cid, deleted, link, linkHeight, linkWidth, locked, parentCid, pinned, postCid, reason, removed, state, subplebbitAddress, timestamp, thumbnailUrl } =
post || {};
const boardPath = subplebbitAddress ? getBoardPath(subplebbitAddress, directories) : undefined;
const displayBoardPath =
boardPath && subplebbitAddress
? boardPath !== subplebbitAddress
? boardPath
: subplebbitAddress.endsWith('.eth') || subplebbitAddress.endsWith('.sol')
? subplebbitAddress
: Plebbit.getShortAddress({ address: subplebbitAddress })
: undefined;
const isReply = parentCid;
const title = post?.title?.trim();
const { address, shortAddress } = author || {};
@@ -70,6 +78,7 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos
const isInAllView = isAllView(location.pathname);
const isInPostPageView = isPostPageView(location.pathname, params);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
const isInModView = isModView(location.pathname);
const isInModQueueView = isModQueueView(location.pathname);
const { getAlertThresholdSeconds } = useModQueueStore();
const currentTime = useCurrentTime();
@@ -304,10 +313,10 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos
)}
</span>
<span className={styles.dateTimePostNum}>
{subplebbitAddress && (isInAllView || isInSubscriptionsView) && !isReply && boardPath && (
{subplebbitAddress && (isInAllView || isInSubscriptionsView || isInModView) && !isReply && boardPath && displayBoardPath && (
<div className={styles.postNumLink}>
{' '}
<Link to={`/${boardPath}`}>Board: {boardPath}</Link>
<Link to={`/${boardPath}`}>Board: {displayBoardPath}</Link>
</div>
)}
{isInModQueueView && isOverThreshold ? (