Using captcha_solved

This commit is contained in:
danidfra 2024-10-10 17:28:56 -03:00
parent 162b0042ed
commit 3f6d589e93
4 changed files with 8 additions and 11 deletions

View File

@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { closeModal } from 'soapbox/actions/modals'; import { closeModal } from 'soapbox/actions/modals';
import { startOnboarding } from 'soapbox/actions/onboarding';
import { useApi, useAppDispatch, useInstance } from 'soapbox/hooks'; import { useApi, useAppDispatch, useInstance } from 'soapbox/hooks';
import { captchaSchema, type CaptchaData } from 'soapbox/schemas/captcha'; import { captchaSchema, type CaptchaData } from 'soapbox/schemas/captcha';
import toast from 'soapbox/toast'; import toast from 'soapbox/toast';
@ -73,7 +72,6 @@ const useCaptcha = () => {
dispatch(closeModal('CAPTCHA')); dispatch(closeModal('CAPTCHA'));
toast.success(messages.sucessMessage); toast.success(messages.sucessMessage);
dispatch(startOnboarding());
}); });
} catch (e) { } catch (e) {
setTryAgain(true); setTryAgain(true);

View File

@ -1,9 +1,7 @@
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { startOnboarding } from 'soapbox/actions/onboarding';
import { Modal, Stack } from 'soapbox/components/ui'; import { Modal, Stack } from 'soapbox/components/ui';
import { useAppDispatch } from 'soapbox/hooks';
import Captcha from './captcha'; import Captcha from './captcha';
@ -12,13 +10,9 @@ interface ICaptchaModal {
} }
const CaptchaModal: React.FC<ICaptchaModal> = ({ onClose }) => { const CaptchaModal: React.FC<ICaptchaModal> = ({ onClose }) => {
const dispatch = useAppDispatch();
return ( return (
<Modal <Modal
title={<FormattedMessage id='nostr_signup.captcha_title' defaultMessage='Human Verification' />} onClose={() => { title={<FormattedMessage id='nostr_signup.captcha_title' defaultMessage='Human Verification' />} width='sm'
onClose();
dispatch(startOnboarding());
}} width='sm'
> >
<Stack justifyContent='center' alignItems='center' space={4}> <Stack justifyContent='center' alignItems='center' space={4}>
<Captcha /> <Captcha />

View File

@ -3,7 +3,6 @@ import React, { useEffect, useMemo, useState } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { fetchAccount } from 'soapbox/actions/accounts'; import { fetchAccount } from 'soapbox/actions/accounts';
import { openModal } from 'soapbox/actions/modals';
import { logInNostr } from 'soapbox/actions/nostr'; import { logInNostr } from 'soapbox/actions/nostr';
import { closeSidebar } from 'soapbox/actions/sidebar'; import { closeSidebar } from 'soapbox/actions/sidebar';
import CopyableInput from 'soapbox/components/copyable-input'; import CopyableInput from 'soapbox/components/copyable-input';
@ -72,7 +71,6 @@ const KeygenStep: React.FC<IKeygenStep> = ({ onClose }) => {
dispatch(closeSidebar()); dispatch(closeSidebar());
} }
await dispatch(openModal('CAPTCHA'));
}; };
return ( return (

View File

@ -35,11 +35,18 @@ const SoapboxMount = () => {
const soapboxConfig = useSoapboxConfig(); const soapboxConfig = useSoapboxConfig();
const showCaptcha = account && !account?.source?.ditto.captcha_solved;
const needsOnboarding = useAppSelector(state => state.onboarding.needsOnboarding); const needsOnboarding = useAppSelector(state => state.onboarding.needsOnboarding);
const showOnboarding = account && needsOnboarding; const showOnboarding = account && needsOnboarding;
if (showCaptcha) {
dispatch(openModal('CAPTCHA'));
}
if (showOnboarding) { if (showOnboarding) {
dispatch(openModal('ONBOARDING_FLOW')); dispatch(openModal('ONBOARDING_FLOW'));
} }
const { redirectRootNoLogin, gdpr } = soapboxConfig; const { redirectRootNoLogin, gdpr } = soapboxConfig;
// @ts-ignore: I don't actually know what these should be, lol // @ts-ignore: I don't actually know what these should be, lol