feat(directories): implement features.noSpoilers and features.noSpoilerReplies for board-specific spoiler checkbox

This commit is contained in:
plebeius
2026-02-17 17:35:53 +08:00
parent 2733ab260b
commit 45a6ff0bab
3 changed files with 83 additions and 39 deletions
+13 -8
View File
@@ -9,6 +9,7 @@ import { isValidURL } from '../../lib/utils/url-utils';
import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
import useSelectedTextStore from '../../stores/use-selected-text-store';
import useReplyModalStore from '../../stores/use-reply-modal-store';
import { useDirectoryByAddress } from '../../hooks/use-directories';
import usePublishReply from '../../hooks/use-publish-reply';
import useIsMobile from '../../hooks/use-is-mobile';
import { useFileUpload } from '../../hooks/use-file-upload';
@@ -30,6 +31,8 @@ interface ReplyModalProps {
const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threadNumber, postCid, scrollY, subplebbitAddress }: ReplyModalProps) => {
const { t } = useTranslation();
const directoryEntry = useDirectoryByAddress(subplebbitAddress);
const showSpoilerForReply = directoryEntry?.features?.noSpoilerReplies !== true;
const { setPublishReplyOptions, publishReply, resetPublishReplyOptions, replyIndex } = usePublishReply({
cid: parentCid,
subplebbitAddress,
@@ -343,14 +346,16 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa
{isUploading ? t('uploading') : uploadedFileName || t('no_file_chosen')}
</span>
</span>
<span className={styles.spoilerButton}>
[
<label>
<input type='checkbox' onChange={(e) => setPublishReplyOptions({ spoiler: e.target.checked })} />
{capitalize(t('spoiler'))}?
</label>
]
</span>
{showSpoilerForReply && (
<span className={styles.spoilerButton}>
[
<label>
<input type='checkbox' onChange={(e) => setPublishReplyOptions({ spoiler: e.target.checked })} />
{capitalize(t('spoiler'))}?
</label>
]
</span>
)}
<button className={styles.publishButton} onClick={onPublishReply}>
{t('post')}
</button>