fix(post): content could bypass max character count if posted from other plebbit client

This commit is contained in:
Tom (plebeius.eth)
2025-02-02 12:52:17 +01:00
parent 96794a0c1e
commit b9210dc835
2 changed files with 16 additions and 4 deletions
+8 -2
View File
@@ -296,7 +296,13 @@ const PostMessage = ({ post }: PostProps) => {
const [showOriginal, setShowOriginal] = useState(false);
const [showFullComment, setShowFullComment] = useState(false);
const displayContent = content && !isInPostView && content.length > 1000 && !showFullComment ? content.slice(0, 1000) : content;
const displayContent =
content &&
(!isInPostView && content.length > 1000 && !showFullComment
? content.slice(0, 1000)
: isInPostView && content.length > 2000 && !showFullComment
? content.slice(0, 2000)
: content);
const quotelinkReply = useComment({ commentCid: parentCid });
const isReply = parentCid;
@@ -377,7 +383,7 @@ const PostMessage = ({ post }: PostProps) => {
/>
</span>
)} */}
{content?.length > 1000 && !isInPostView && !showFullComment && (
{((!isInPostView && content?.length > 1000 && !showFullComment) || (isInPostView && content?.length > 2000 && !showFullComment)) && (
<span className={styles.abbr}>
<br />
<Trans i18nKey={'comment_too_long'} shouldUnescape={true} components={{ 1: <span onClick={() => setShowFullComment(true)} /> }} />
+8 -2
View File
@@ -227,7 +227,13 @@ const PostMessageMobile = ({ post }: PostProps) => {
const isInPostView = isPostPageView(location.pathname, params);
const [showFullComment, setShowFullComment] = useState(false);
const displayContent = content && !isInPostView && content.length > 1000 && !showFullComment ? content.slice(0, 1000) : content;
const displayContent =
content &&
(!isInPostView && content.length > 1000 && !showFullComment
? content.slice(0, 1000)
: isInPostView && content.length > 2000 && !showFullComment
? content.slice(0, 2000)
: content);
const quotelinkReply = useComment({ commentCid: parentCid });
const isReply = parentCid;
@@ -308,7 +314,7 @@ const PostMessageMobile = ({ post }: PostProps) => {
/>
</span>
)} */}
{content?.length > 1000 && !isInPostView && !showFullComment && (
{((!isInPostView && content?.length > 1000 && !showFullComment) || (isInPostView && content?.length > 2000 && !showFullComment)) && (
<span className={styles.abbr}>
<br />
<Trans i18nKey={'comment_too_long'} shouldUnescape={true} components={{ 1: <span onClick={() => setShowFullComment(true)} /> }} />