mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Fix ban duration change updating ban expiration when ban checkbox is unchecked
This commit is contained in:
@@ -176,13 +176,17 @@ const EditMenu = ({ post }: { post: Comment }) => {
|
||||
const onBanDurationChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const days = parseInt(e.target.value, 10) || 1;
|
||||
setBanDuration(days);
|
||||
setPublishCommentEditOptions((state) => ({
|
||||
setPublishCommentEditOptions((state) => {
|
||||
// Only update ban expiration if ban is currently enabled (checkbox is checked)
|
||||
const isBanEnabled = state.commentModeration?.author?.banExpiresAt !== undefined;
|
||||
return {
|
||||
...state,
|
||||
commentModeration: {
|
||||
...state.commentModeration,
|
||||
author: { banExpiresAt: daysToTimestampInSeconds(days) },
|
||||
author: isBanEnabled ? { banExpiresAt: daysToTimestampInSeconds(days) } : state.commentModeration?.author,
|
||||
},
|
||||
}));
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const onPurgeCheckbox = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
|
||||
Reference in New Issue
Block a user