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) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
setCaptchaResponse(responseRef.current.value);
|
||||
setIsCaptchaOpen(false);
|
||||
submitCaptcha();
|
||||
}
|
||||
};
|
||||
|
||||
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 (
|
||||
<StyledModal
|
||||
isOpen={isCaptchaOpen}
|
||||
@@ -109,8 +125,7 @@ const CaptchaModal = () => {
|
||||
if (currentChallengeIndex + 1 < totalChallenges) {
|
||||
setCurrentChallengeIndex((currentChallengeIndex + 1) % totalChallenges);
|
||||
} else {
|
||||
setCaptchaResponse(responseRef.current.value);
|
||||
setIsCaptchaOpen(false);
|
||||
handleReturnKeyDown();
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -32,6 +32,7 @@ const Board = () => {
|
||||
setIsCaptchaOpen,
|
||||
isSettingsOpen, setIsSettingsOpen,
|
||||
setPendingComment,
|
||||
setResolveCaptchaPromise,
|
||||
selectedAddress, setSelectedAddress,
|
||||
setSelectedParentCid,
|
||||
setSelectedShortCid,
|
||||
@@ -201,6 +202,8 @@ const Board = () => {
|
||||
|
||||
setCaptchaResponse('');
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
useGeneralStore.getState().setResolveCaptchaPromise(resolve);
|
||||
};
|
||||
|
||||
challengeImg.onerror = () => {
|
||||
|
||||
@@ -31,6 +31,9 @@ const useGeneralStore = create((set) => ({
|
||||
|
||||
publishedComment: '',
|
||||
setPublishedComment: (comment) => set({ publishedComment: comment }),
|
||||
|
||||
resolveCaptchaPromise: null,
|
||||
setResolveCaptchaPromise: (resolve) => set({ resolveCaptchaPromise: resolve }),
|
||||
|
||||
selectedAddress: '',
|
||||
setSelectedAddress: (address) => set({ selectedAddress: address }),
|
||||
|
||||
Reference in New Issue
Block a user