Merge branch 'fix-onboarding-modal' into 'main'
Make the onboarding modal show up again (during Nostr login flow) See merge request soapbox-pub/soapbox!3317
This commit is contained in:
commit
e46211bdc7
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
import { fetchMe } from 'soapbox/actions/me.ts';
|
||||||
import { closeModal } from 'soapbox/actions/modals.ts';
|
import { closeModal } from 'soapbox/actions/modals.ts';
|
||||||
import { HTTPError } from 'soapbox/api/HTTPError.ts';
|
import { HTTPError } from 'soapbox/api/HTTPError.ts';
|
||||||
import { useApi } from 'soapbox/hooks/useApi.ts';
|
import { useApi } from 'soapbox/hooks/useApi.ts';
|
||||||
|
@ -9,8 +10,6 @@ import { useInstance } from 'soapbox/hooks/useInstance.ts';
|
||||||
import { captchaSchema, type CaptchaData } from 'soapbox/schemas/captcha.ts';
|
import { captchaSchema, type CaptchaData } from 'soapbox/schemas/captcha.ts';
|
||||||
import toast from 'soapbox/toast.tsx';
|
import toast from 'soapbox/toast.tsx';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
sucessMessage: { id: 'nostr_signup.captcha_message.sucess', defaultMessage: 'Incredible! You\'ve successfully completed the captcha.' },
|
sucessMessage: { id: 'nostr_signup.captcha_message.sucess', defaultMessage: 'Incredible! You\'ve successfully completed the captcha.' },
|
||||||
wrongMessage: { id: 'nostr_signup.captcha_message.wrong', defaultMessage: 'Oops! It looks like your captcha response was incorrect. Please try again.' },
|
wrongMessage: { id: 'nostr_signup.captcha_message.wrong', defaultMessage: 'Oops! It looks like your captcha response was incorrect. Please try again.' },
|
||||||
|
@ -66,12 +65,10 @@ const useCaptcha = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.post(`/api/v1/ditto/captcha/${captcha.id}/verify`, result).then(() => {
|
await api.post(`/api/v1/ditto/captcha/${captcha.id}/verify`, result);
|
||||||
setTryAgain(true);
|
|
||||||
|
|
||||||
dispatch(closeModal('CAPTCHA'));
|
dispatch(closeModal('CAPTCHA'));
|
||||||
|
await dispatch(fetchMe()); // refetch account so `captcha_solved` changes.
|
||||||
toast.success(messages.sucessMessage);
|
toast.success(messages.sucessMessage);
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setTryAgain(true);
|
setTryAgain(true);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import { fetchAccount } from 'soapbox/actions/accounts.ts';
|
import { fetchAccount } from 'soapbox/actions/accounts.ts';
|
||||||
import { logInNostr } from 'soapbox/actions/nostr.ts';
|
import { logInNostr } from 'soapbox/actions/nostr.ts';
|
||||||
|
import { startOnboarding } from 'soapbox/actions/onboarding.ts';
|
||||||
import { closeSidebar } from 'soapbox/actions/sidebar.ts';
|
import { closeSidebar } from 'soapbox/actions/sidebar.ts';
|
||||||
import EmojiGraphic from 'soapbox/components/emoji-graphic.tsx';
|
import EmojiGraphic from 'soapbox/components/emoji-graphic.tsx';
|
||||||
import Button from 'soapbox/components/ui/button.tsx';
|
import Button from 'soapbox/components/ui/button.tsx';
|
||||||
|
@ -79,6 +80,7 @@ const KeygenStep: React.FC<IKeygenStep> = ({ onClose }) => {
|
||||||
dispatch(closeSidebar());
|
dispatch(closeSidebar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch(startOnboarding());
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -39,9 +39,11 @@ const SoapboxMount = () => {
|
||||||
}
|
}
|
||||||
}, [showCaptcha]);
|
}, [showCaptcha]);
|
||||||
|
|
||||||
if (showOnboarding) {
|
useEffect(() => {
|
||||||
|
if (showOnboarding && !showCaptcha) {
|
||||||
dispatch(openModal('ONBOARDING_FLOW'));
|
dispatch(openModal('ONBOARDING_FLOW'));
|
||||||
}
|
}
|
||||||
|
}, [showOnboarding, showCaptcha]);
|
||||||
|
|
||||||
const { redirectRootNoLogin, gdpr } = soapboxConfig;
|
const { redirectRootNoLogin, gdpr } = soapboxConfig;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue