From 2563209ae3b9a42a28c19a135c7696fa7fe99333 Mon Sep 17 00:00:00 2001 From: alipov_d Date: Wed, 7 Jun 2023 13:44:57 +0200 Subject: [PATCH] fix: 400 error editing posts and comment This is a backport from the master --- src/discussions/comments/comment/CommentEditor.jsx | 4 +++- src/discussions/posts/post-editor/PostEditor.jsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/discussions/comments/comment/CommentEditor.jsx b/src/discussions/comments/comment/CommentEditor.jsx index 2742836b..2fe725b2 100644 --- a/src/discussions/comments/comment/CommentEditor.jsx +++ b/src/discussions/comments/comment/CommentEditor.jsx @@ -55,7 +55,9 @@ function CommentEditor({ const initialValues = { comment: comment.rawBody, - editReasonCode: comment?.lastEdit?.reasonCode || (userIsStaff ? 'violates-guidelines' : ''), + editReasonCode: comment?.lastEdit?.reasonCode || ( + userIsStaff && canDisplayEditReason ? 'violates-guidelines' : undefined + ), }; const handleCloseEditor = (resetForm) => { diff --git a/src/discussions/posts/post-editor/PostEditor.jsx b/src/discussions/posts/post-editor/PostEditor.jsx index 0ab48773..a4922f56 100644 --- a/src/discussions/posts/post-editor/PostEditor.jsx +++ b/src/discussions/posts/post-editor/PostEditor.jsx @@ -138,7 +138,9 @@ function PostEditor({ follow: isEmpty(post?.following) ? true : post?.following, anonymous: allowAnonymous ? false : undefined, anonymousToPeers: allowAnonymousToPeers ? false : undefined, - editReasonCode: post?.lastEdit?.reasonCode || (userIsStaff ? 'violates-guidelines' : ''), + editReasonCode: post?.lastEdit?.reasonCode || ( + userIsStaff && canDisplayEditReason ? 'violates-guidelines' : undefined + ), cohort: post?.cohort || 'default', };