From 2bc2827f835213d26c368e9fc45b845117fd4c0e Mon Sep 17 00:00:00 2001 From: plebeius Date: Sun, 1 Mar 2026 15:27:27 +0800 Subject: [PATCH] fix(post form): default link label to 'link to file' on /all/ and /subs/ --- src/components/post-form/post-form.tsx | 3 ++- src/components/reply-modal/reply-modal.tsx | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx index ceb829e8..493c8b1a 100644 --- a/src/components/post-form/post-form.tsx +++ b/src/components/post-form/post-form.tsx @@ -324,7 +324,8 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: const directoryEntry = useDirectoryByAddress(effectiveBoardAddress); const showSpoilerForPost = directoryEntry?.features?.noSpoilers !== true; const showSpoilerForReply = directoryEntry?.features?.noSpoilerReplies !== true; - const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; + const requirePostLinkIsMediaFeature = directoryEntry?.features?.requirePostLinkIsMedia; + const requirePostLinkIsMedia = requirePostLinkIsMediaFeature === true || (requirePostLinkIsMediaFeature === undefined && (isInAllView || isInSubscriptionsView)); const { accountSubplebbits } = useAccountSubplebbits(); const accountSubplebbitAddresses = Object.keys(accountSubplebbits); diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index 3b2a4662..34057c90 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -35,9 +35,14 @@ interface ReplyModalProps { const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threadNumber, postCid, scrollY, subplebbitAddress }: ReplyModalProps) => { const { t } = useTranslation(); + const location = useLocation(); + const params = useParams(); + const isInAllView = isAllView(location.pathname); + const isInSubscriptionsView = isSubscriptionsView(location.pathname, params); const directoryEntry = useDirectoryByAddress(subplebbitAddress); const showSpoilerForReply = directoryEntry?.features?.noSpoilerReplies !== true; - const requirePostLinkIsMedia = directoryEntry?.features?.requirePostLinkIsMedia === true; + const requirePostLinkIsMediaFeature = directoryEntry?.features?.requirePostLinkIsMedia; + const requirePostLinkIsMedia = requirePostLinkIsMediaFeature === true || (requirePostLinkIsMediaFeature === undefined && (isInAllView || isInSubscriptionsView)); const { setPublishReplyOptions, publishReply, resetPublishReplyOptions, replyIndex } = usePublishReply({ cid: parentCid, subplebbitAddress, @@ -148,9 +153,6 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa } }, [parentCid]); - const location = useLocation(); - const isInAllView = isAllView(location.pathname); - const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams()); const currentTime = useCurrentTime(); // Only subscribe to updatedAt to avoid rerenders from updatingState changes const updatedAt = useSubplebbitField(subplebbitAddress, (subplebbit) => subplebbit?.updatedAt);