fix(edit-menu): use correct banExpiresAt path in commentModeration.author

This commit is contained in:
plebeius
2026-01-09 16:43:21 +01:00
parent ac850ca830
commit a959f14290
2 changed files with 32 additions and 9 deletions
+25 -9
View File
@@ -75,7 +75,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
purged: purged ?? false,
spoiler: spoiler ?? false,
reason,
banExpiresAt: post?.commentModeration?.banExpiresAt,
author: post?.commentModeration?.author?.banExpiresAt ? { banExpiresAt: post.commentModeration.author.banExpiresAt } : undefined,
}
: undefined,
onChallenge: (...args: any) => addChallenge([...args, post]),
@@ -120,7 +120,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
purged: publishCommentEditOptions.commentModeration?.purged,
spoiler: publishCommentEditOptions.commentModeration?.spoiler,
reason: publishCommentEditOptions.reason,
banExpiresAt: publishCommentEditOptions.commentModeration?.banExpiresAt,
author: publishCommentEditOptions.commentModeration?.author,
},
author: account?.author,
onChallenge: (...args: any) => addChallenge([...args, post]),
@@ -141,7 +141,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
}, [defaultPublishEditOptions]);
const [banDuration, setBanDuration] = useState(() =>
publishCommentEditOptions.commentModeration?.banExpiresAt ? timestampToDays(publishCommentEditOptions.commentModeration.banExpiresAt) : 1,
publishCommentEditOptions.commentModeration?.author?.banExpiresAt ? timestampToDays(publishCommentEditOptions.commentModeration.author.banExpiresAt) : 1,
);
const onCheckbox = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -151,10 +151,18 @@ const EditMenu = ({ post }: { post: Comment }) => {
const newState = { ...state };
if (isAccountMod) {
newState.commentModeration = {
...newState.commentModeration,
[id === 'banUser' ? 'banExpiresAt' : id]: id === 'banUser' ? (checked ? daysToTimestampInSeconds(banDuration) : undefined) : checked,
};
if (id === 'banUser') {
const banValue = checked ? daysToTimestampInSeconds(banDuration) : undefined;
newState.commentModeration = {
...newState.commentModeration,
author: banValue ? { banExpiresAt: banValue } : undefined,
};
} else {
newState.commentModeration = {
...newState.commentModeration,
[id]: checked,
};
}
}
if (isAccountCommentAuthor) {
@@ -170,7 +178,10 @@ const EditMenu = ({ post }: { post: Comment }) => {
setBanDuration(days);
setPublishCommentEditOptions((state) => ({
...state,
commentAuthor: { ...state.commentAuthor, banExpiresAt: daysToTimestampInSeconds(days) },
commentModeration: {
...state.commentModeration,
author: { banExpiresAt: daysToTimestampInSeconds(days) },
},
}));
};
@@ -332,7 +343,12 @@ const EditMenu = ({ post }: { post: Comment }) => {
<div className={styles.menuItem}>
[
<label>
<input onChange={onCheckbox} checked={publishCommentEditOptions.commentModeration?.banExpiresAt !== undefined} type='checkbox' id='banUser' />
<input
onChange={onCheckbox}
checked={publishCommentEditOptions.commentModeration?.author?.banExpiresAt !== undefined}
type='checkbox'
id='banUser'
/>
<Trans
i18nKey='ban_user_for'
shouldUnescape={true}
+7
View File
@@ -655,3 +655,10 @@
width: 6px;
display: inline-block;
}
.removedContent {
color: red;
font-weight: 700;
text-transform: uppercase;
}