mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add dynamic challenge modal title
This commit is contained in:
@@ -11,7 +11,11 @@ const CaptchaModal = () => {
|
||||
pendingComment,
|
||||
selectedStyle,
|
||||
setCaptchaResponse,
|
||||
isAuthorDelete, setIsAuthorDelete,
|
||||
isAuthorEdit, setIsAuthorEdit,
|
||||
isCaptchaOpen, setIsCaptchaOpen,
|
||||
isModEdit, setIsModEdit,
|
||||
resolveCaptchaPromise,
|
||||
selectedShortCid,
|
||||
} = useGeneralStore(state => state);
|
||||
|
||||
@@ -22,8 +26,18 @@ const CaptchaModal = () => {
|
||||
const responseRef = useRef();
|
||||
const nodeRef = useRef(null);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!isCaptchaOpen) {
|
||||
setIsAuthorDelete(false);
|
||||
setIsAuthorEdit(false);
|
||||
setIsModEdit(false);
|
||||
}
|
||||
}, [isCaptchaOpen, setIsAuthorDelete, setIsAuthorEdit, setIsModEdit]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => setIsMobile(window.innerWidth <= 480);
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
@@ -50,6 +64,7 @@ const CaptchaModal = () => {
|
||||
}
|
||||
}, [challengesArray]);
|
||||
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
@@ -57,10 +72,11 @@ const CaptchaModal = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleReturnKeyDown = () => {
|
||||
submitCaptcha((response) => {
|
||||
useGeneralStore.getState().setCaptchaResponse(response);
|
||||
useGeneralStore.getState().resolveCaptchaPromise(response);
|
||||
submitCaptcha((response) => {
|
||||
setCaptchaResponse(response);
|
||||
resolveCaptchaPromise(response);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -72,13 +88,15 @@ const CaptchaModal = () => {
|
||||
if (callback) {
|
||||
callback(responseRef.current.value);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<StyledModal
|
||||
isOpen={isCaptchaOpen}
|
||||
onRequestClose={() => setIsCaptchaOpen(false)}
|
||||
onRequestClose={() => {
|
||||
submitCaptcha();
|
||||
setIsCaptchaOpen(false);}}
|
||||
contentLabel="Captcha Modal"
|
||||
shouldCloseOnEsc={false}
|
||||
shouldCloseOnOverlayClick={false}
|
||||
@@ -87,7 +105,10 @@ const CaptchaModal = () => {
|
||||
<Draggable handle=".modal-header" nodeRef={nodeRef} disabled={isMobile}>
|
||||
<div className="modal-content" ref={nodeRef}>
|
||||
<div className="modal-header">
|
||||
{pendingComment.parentCid ?
|
||||
{isModEdit ? "Challenge for Moderator Action" :
|
||||
isAuthorEdit ? "Challenge for Editing Post" :
|
||||
isAuthorDelete ? "Challenge for Deleting Post" :
|
||||
pendingComment.parentCid ?
|
||||
("Challenges for Reply to c/" + selectedShortCid) :
|
||||
"Challenges for New Thread"}
|
||||
<button className="icon" onClick={() => setIsCaptchaOpen(false)} title="close" />
|
||||
|
||||
@@ -15,6 +15,7 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
|
||||
setCaptchaResponse,
|
||||
setChallengesArray,
|
||||
setIsCaptchaOpen,
|
||||
setIsModEdit,
|
||||
moderatingCommentCid,
|
||||
setResolveCaptchaPromise,
|
||||
} = useGeneralStore(state => state);
|
||||
@@ -221,6 +222,7 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
|
||||
reason: reason
|
||||
}));
|
||||
setTriggerPublishCommentEdit(true);
|
||||
setIsModEdit(true);
|
||||
handleCloseModal();
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -41,6 +41,8 @@ const Board = () => {
|
||||
setChallengesArray,
|
||||
defaultSubplebbits,
|
||||
editedComment,
|
||||
setIsAuthorDelete,
|
||||
setIsAuthorEdit,
|
||||
setIsCaptchaOpen,
|
||||
isModerationOpen, setIsModerationOpen,
|
||||
isSettingsOpen, setIsSettingsOpen,
|
||||
@@ -419,6 +421,8 @@ const Board = () => {
|
||||
<button onClick={onClose}>No</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsAuthorDelete(true);
|
||||
setIsAuthorEdit(false);
|
||||
setCommentCid(commentCid);
|
||||
setPublishCommentEditOptions(prevOptions => ({
|
||||
...prevOptions,
|
||||
@@ -440,6 +444,8 @@ const Board = () => {
|
||||
|
||||
const handleAuthorEditClick = (comment) => {
|
||||
handleOptionClick(comment.cid);
|
||||
setIsAuthorEdit(true);
|
||||
setIsAuthorDelete(false);
|
||||
setCommentCid(comment.cid);
|
||||
setOriginalCommentContent(comment.content);
|
||||
setIsEditModalOpen(true);
|
||||
|
||||
@@ -33,6 +33,8 @@ const Catalog = () => {
|
||||
setChallengesArray,
|
||||
defaultSubplebbits,
|
||||
editedComment,
|
||||
setIsAuthorDelete,
|
||||
setIsAuthorEdit,
|
||||
setIsCaptchaOpen,
|
||||
isModerationOpen, setIsModerationOpen,
|
||||
isSettingsOpen, setIsSettingsOpen,
|
||||
@@ -354,6 +356,8 @@ const Catalog = () => {
|
||||
<button onClick={onClose}>No</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsAuthorDelete(true);
|
||||
setIsAuthorEdit(false);
|
||||
setCommentCid(commentCid);
|
||||
setPublishCommentEditOptions(prevOptions => ({
|
||||
...prevOptions,
|
||||
@@ -376,6 +380,8 @@ const Catalog = () => {
|
||||
|
||||
const handleAuthorEditClick = (comment) => {
|
||||
handleOptionClick(comment.cid);
|
||||
setIsAuthorEdit(true);
|
||||
setIsAuthorDelete(false);
|
||||
setCommentCid(comment.cid);
|
||||
setOriginalCommentContent(comment.content);
|
||||
setIsEditModalOpen(true);
|
||||
|
||||
@@ -40,6 +40,8 @@ const Thread = () => {
|
||||
setChallengesArray,
|
||||
defaultSubplebbits,
|
||||
editedComment,
|
||||
setIsAuthorDelete,
|
||||
setIsAuthorEdit,
|
||||
setIsCaptchaOpen,
|
||||
isModerationOpen, setIsModerationOpen,
|
||||
isSettingsOpen, setIsSettingsOpen,
|
||||
@@ -391,6 +393,8 @@ const Thread = () => {
|
||||
<button onClick={onClose}>No</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsAuthorDelete(true);
|
||||
setIsAuthorEdit(false);
|
||||
setCommentCid(commentCid);
|
||||
setPublishCommentEditOptions(prevOptions => ({
|
||||
...prevOptions,
|
||||
@@ -412,6 +416,8 @@ const Thread = () => {
|
||||
|
||||
const handleAuthorEditClick = (comment) => {
|
||||
handleOptionClick(comment.cid);
|
||||
setIsAuthorEdit(true);
|
||||
setIsAuthorDelete(false);
|
||||
setCommentCid(comment.cid);
|
||||
setOriginalCommentContent(comment.content);
|
||||
setIsEditModalOpen(true);
|
||||
@@ -837,7 +843,7 @@ const Thread = () => {
|
||||
>
|
||||
<ul className="post-menu-catalog">
|
||||
<li onClick={() => handleOptionClick(comment.cid)}>Hide thread</li>
|
||||
{comment.author.shortAddress === account?.author.shortAddress ? (
|
||||
{comment.author?.shortAddress === account?.author.shortAddress ? (
|
||||
<>
|
||||
<li onClick={() => handleAuthorEditClick(comment)}>Edit post</li>
|
||||
<li onClick={() => handleAuthorDeleteClick(comment.cid)}>Delete post</li>
|
||||
@@ -845,7 +851,7 @@ const Thread = () => {
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
<>
|
||||
{comment.author.shortAddress === account?.author.shortAddress ? (
|
||||
{comment.author?.shortAddress === account?.author.shortAddress ? (
|
||||
null
|
||||
) : (
|
||||
<li onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user