mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fixed CaptchaModal post button
This commit is contained in:
@@ -40,11 +40,27 @@ const CaptchaModal = () => {
|
|||||||
const handleKeyDown = (event) => {
|
const handleKeyDown = (event) => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setCaptchaResponse(responseRef.current.value);
|
submitCaptcha();
|
||||||
setIsCaptchaOpen(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleReturnKeyDown = () => {
|
||||||
|
submitCaptcha((response) => {
|
||||||
|
useGeneralStore.getState().setCaptchaResponse(response);
|
||||||
|
useGeneralStore.getState().resolveCaptchaPromise(response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const submitCaptcha = (callback) => {
|
||||||
|
setCaptchaResponse(responseRef.current.value);
|
||||||
|
setIsCaptchaOpen(false);
|
||||||
|
if (callback) {
|
||||||
|
callback(responseRef.current.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledModal
|
<StyledModal
|
||||||
isOpen={isCaptchaOpen}
|
isOpen={isCaptchaOpen}
|
||||||
@@ -109,8 +125,7 @@ const CaptchaModal = () => {
|
|||||||
if (currentChallengeIndex + 1 < totalChallenges) {
|
if (currentChallengeIndex + 1 < totalChallenges) {
|
||||||
setCurrentChallengeIndex((currentChallengeIndex + 1) % totalChallenges);
|
setCurrentChallengeIndex((currentChallengeIndex + 1) % totalChallenges);
|
||||||
} else {
|
} else {
|
||||||
setCaptchaResponse(responseRef.current.value);
|
handleReturnKeyDown();
|
||||||
setIsCaptchaOpen(false);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const Board = () => {
|
|||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
isSettingsOpen, setIsSettingsOpen,
|
isSettingsOpen, setIsSettingsOpen,
|
||||||
setPendingComment,
|
setPendingComment,
|
||||||
|
setResolveCaptchaPromise,
|
||||||
selectedAddress, setSelectedAddress,
|
selectedAddress, setSelectedAddress,
|
||||||
setSelectedParentCid,
|
setSelectedParentCid,
|
||||||
setSelectedShortCid,
|
setSelectedShortCid,
|
||||||
@@ -201,6 +202,8 @@ const Board = () => {
|
|||||||
|
|
||||||
setCaptchaResponse('');
|
setCaptchaResponse('');
|
||||||
document.addEventListener('keydown', handleKeyDown);
|
document.addEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
|
useGeneralStore.getState().setResolveCaptchaPromise(resolve);
|
||||||
};
|
};
|
||||||
|
|
||||||
challengeImg.onerror = () => {
|
challengeImg.onerror = () => {
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ const useGeneralStore = create((set) => ({
|
|||||||
|
|
||||||
publishedComment: '',
|
publishedComment: '',
|
||||||
setPublishedComment: (comment) => set({ publishedComment: comment }),
|
setPublishedComment: (comment) => set({ publishedComment: comment }),
|
||||||
|
|
||||||
|
resolveCaptchaPromise: null,
|
||||||
|
setResolveCaptchaPromise: (resolve) => set({ resolveCaptchaPromise: resolve }),
|
||||||
|
|
||||||
selectedAddress: '',
|
selectedAddress: '',
|
||||||
setSelectedAddress: (address) => set({ selectedAddress: address }),
|
setSelectedAddress: (address) => set({ selectedAddress: address }),
|
||||||
|
|||||||
Reference in New Issue
Block a user