From a959f14290f7262483ab3058dd2d3431be1b682e Mon Sep 17 00:00:00 2001 From: plebeius Date: Fri, 9 Jan 2026 16:43:21 +0100 Subject: [PATCH] fix(edit-menu): use correct banExpiresAt path in commentModeration.author --- src/components/edit-menu/edit-menu.tsx | 34 +++++++++++++++++++------- src/views/post/post.module.css | 7 ++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/components/edit-menu/edit-menu.tsx b/src/components/edit-menu/edit-menu.tsx index 3a09e71e..745692a9 100644 --- a/src/components/edit-menu/edit-menu.tsx +++ b/src/components/edit-menu/edit-menu.tsx @@ -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) => { @@ -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 }) => {
[