fix moderation modal state

This commit is contained in:
plebeius.eth
2023-08-18 17:25:41 +02:00
parent 6783efd761
commit fec617d209
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -22,9 +22,9 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
const comment = useComment({commentCid: moderatingCommentCid});
const [pin, setPin] = useState(comment?.pinned);
const [pin, setPin] = useState(comment.pinned);
const [deleteThread, setDeleteThread] = useState(deletePost);
const [close, setClose] = useState(comment?.locked);
const [close, setClose] = useState(comment.locked);
const [reason, setReason] = useState('');
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
@@ -32,16 +32,24 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
const [, setNewSuccessMessage] = useSuccess();
useEffect(() => {
setPin(comment.pinned);
setClose(comment.locked);
}, [comment]);
useEffect(() => {
setDeleteThread(deletePost);
}, [deletePost]);
useEffect(() => {
if (!isOpen) {
setDeleteThread(deletePost);
}
}, [isOpen, deletePost]);
const handleCloseModal = () => {
setDeleteThread(false);
closeModal();
@@ -82,7 +82,7 @@ export const StyledModal = styled(Modal)`
}
.settings-cat {
display: ${({ expanded }) => index => (expanded.includes(index) ? "block" : "none")};
display: ${({ expanded }) => index => (expanded?.includes(index) ? "block" : "none")};
margin: 5px;
}