From f6348f0e66eafef80361734b7cd3ca5c441dced2 Mon Sep 17 00:00:00 2001 From: plebeius Date: Fri, 9 Jan 2026 17:22:05 +0100 Subject: [PATCH] Fix ban duration change updating ban expiration when ban checkbox is unchecked --- src/components/edit-menu/edit-menu.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/edit-menu/edit-menu.tsx b/src/components/edit-menu/edit-menu.tsx index 745692a9..ed969bea 100644 --- a/src/components/edit-menu/edit-menu.tsx +++ b/src/components/edit-menu/edit-menu.tsx @@ -176,13 +176,17 @@ const EditMenu = ({ post }: { post: Comment }) => { const onBanDurationChange = (e: React.ChangeEvent) => { const days = parseInt(e.target.value, 10) || 1; setBanDuration(days); - setPublishCommentEditOptions((state) => ({ - ...state, - commentModeration: { - ...state.commentModeration, - author: { banExpiresAt: daysToTimestampInSeconds(days) }, - }, - })); + 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: isBanEnabled ? { banExpiresAt: daysToTimestampInSeconds(days) } : state.commentModeration?.author, + }, + }; + }); }; const onPurgeCheckbox = (e: React.ChangeEvent) => {