mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(edit-menu): use correct banExpiresAt path in commentModeration.author
This commit is contained in:
@@ -75,7 +75,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
|||||||
purged: purged ?? false,
|
purged: purged ?? false,
|
||||||
spoiler: spoiler ?? false,
|
spoiler: spoiler ?? false,
|
||||||
reason,
|
reason,
|
||||||
banExpiresAt: post?.commentModeration?.banExpiresAt,
|
author: post?.commentModeration?.author?.banExpiresAt ? { banExpiresAt: post.commentModeration.author.banExpiresAt } : undefined,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
onChallenge: (...args: any) => addChallenge([...args, post]),
|
onChallenge: (...args: any) => addChallenge([...args, post]),
|
||||||
@@ -120,7 +120,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
|||||||
purged: publishCommentEditOptions.commentModeration?.purged,
|
purged: publishCommentEditOptions.commentModeration?.purged,
|
||||||
spoiler: publishCommentEditOptions.commentModeration?.spoiler,
|
spoiler: publishCommentEditOptions.commentModeration?.spoiler,
|
||||||
reason: publishCommentEditOptions.reason,
|
reason: publishCommentEditOptions.reason,
|
||||||
banExpiresAt: publishCommentEditOptions.commentModeration?.banExpiresAt,
|
author: publishCommentEditOptions.commentModeration?.author,
|
||||||
},
|
},
|
||||||
author: account?.author,
|
author: account?.author,
|
||||||
onChallenge: (...args: any) => addChallenge([...args, post]),
|
onChallenge: (...args: any) => addChallenge([...args, post]),
|
||||||
@@ -141,7 +141,7 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
|||||||
}, [defaultPublishEditOptions]);
|
}, [defaultPublishEditOptions]);
|
||||||
|
|
||||||
const [banDuration, setBanDuration] = useState(() =>
|
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>) => {
|
const onCheckbox = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
@@ -151,10 +151,18 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
|||||||
const newState = { ...state };
|
const newState = { ...state };
|
||||||
|
|
||||||
if (isAccountMod) {
|
if (isAccountMod) {
|
||||||
newState.commentModeration = {
|
if (id === 'banUser') {
|
||||||
...newState.commentModeration,
|
const banValue = checked ? daysToTimestampInSeconds(banDuration) : undefined;
|
||||||
[id === 'banUser' ? 'banExpiresAt' : id]: id === 'banUser' ? (checked ? daysToTimestampInSeconds(banDuration) : undefined) : checked,
|
newState.commentModeration = {
|
||||||
};
|
...newState.commentModeration,
|
||||||
|
author: banValue ? { banExpiresAt: banValue } : undefined,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
newState.commentModeration = {
|
||||||
|
...newState.commentModeration,
|
||||||
|
[id]: checked,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAccountCommentAuthor) {
|
if (isAccountCommentAuthor) {
|
||||||
@@ -170,7 +178,10 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
|||||||
setBanDuration(days);
|
setBanDuration(days);
|
||||||
setPublishCommentEditOptions((state) => ({
|
setPublishCommentEditOptions((state) => ({
|
||||||
...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}>
|
<div className={styles.menuItem}>
|
||||||
[
|
[
|
||||||
<label>
|
<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
|
<Trans
|
||||||
i18nKey='ban_user_for'
|
i18nKey='ban_user_for'
|
||||||
shouldUnescape={true}
|
shouldUnescape={true}
|
||||||
|
|||||||
@@ -655,3 +655,10 @@
|
|||||||
width: 6px;
|
width: 6px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.removedContent {
|
||||||
|
color: red;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user