feat: stop polling if restoring and we push the back button

pull/3137/head
yougotwill 9 months ago
parent fd7d6e322b
commit 4478ee160d

@ -28,12 +28,14 @@ export const BackButtonWithinContainer = ({
children, children,
margin, margin,
callback, callback,
onQuitVisible,
shouldQuitOnClick, shouldQuitOnClick,
quitMessage, quitMessage,
}: { }: {
children: ReactNode; children: ReactNode;
margin?: string; margin?: string;
callback?: () => void; callback?: () => void;
onQuitVisible?: () => void;
shouldQuitOnClick?: boolean; shouldQuitOnClick?: boolean;
quitMessage?: string; quitMessage?: string;
}) => { }) => {
@ -48,6 +50,7 @@ export const BackButtonWithinContainer = ({
<div style={{ margin }}> <div style={{ margin }}>
<BackButton <BackButton
callback={callback} callback={callback}
onQuitVisible={onQuitVisible}
shouldQuitOnClick={shouldQuitOnClick} shouldQuitOnClick={shouldQuitOnClick}
quitMessage={quitMessage} quitMessage={quitMessage}
/> />
@ -59,10 +62,12 @@ export const BackButtonWithinContainer = ({
export const BackButton = ({ export const BackButton = ({
callback, callback,
onQuitVisible,
shouldQuitOnClick, shouldQuitOnClick,
quitMessage, quitMessage,
}: { }: {
callback?: () => void; callback?: () => void;
onQuitVisible?: () => void;
shouldQuitOnClick?: boolean; shouldQuitOnClick?: boolean;
quitMessage?: string; quitMessage?: string;
}) => { }) => {
@ -81,6 +86,9 @@ export const BackButton = ({
padding={'0'} padding={'0'}
onClick={() => { onClick={() => {
if (shouldQuitOnClick && quitMessage) { if (shouldQuitOnClick && quitMessage) {
if (onQuitVisible) {
onQuitVisible();
}
dispatch( dispatch(
updateQuitModal({ updateQuitModal({
title: window.i18n('warning'), title: window.i18n('warning'),

@ -117,6 +117,8 @@ async function signInWithNewDisplayName({
} }
} }
let abortController = new AbortController();
export const RestoreAccount = () => { export const RestoreAccount = () => {
const step = useOnboardAccountRestorationStep(); const step = useOnboardAccountRestorationStep();
const recoveryPassword = useRecoveryPassword(); const recoveryPassword = useRecoveryPassword();
@ -136,8 +138,8 @@ export const RestoreAccount = () => {
const trimmedPassword = recoveryPassword.trim(); const trimmedPassword = recoveryPassword.trim();
setRecoveryPassword(trimmedPassword); setRecoveryPassword(trimmedPassword);
const abortController = new AbortController();
try { try {
abortController = new AbortController();
dispatch(setProgress(0)); dispatch(setProgress(0));
dispatch(setAccountRestorationStep(AccountRestoration.Loading)); dispatch(setAccountRestorationStep(AccountRestoration.Loading));
await signInAndFetchDisplayName({ await signInAndFetchDisplayName({
@ -201,6 +203,23 @@ export const RestoreAccount = () => {
margin={'2px 0 0 -36px'} margin={'2px 0 0 -36px'}
shouldQuitOnClick={step !== AccountRestoration.RecoveryPassword} shouldQuitOnClick={step !== AccountRestoration.RecoveryPassword}
quitMessage={window.i18n('onboardingBackLoadAccount')} quitMessage={window.i18n('onboardingBackLoadAccount')}
onQuitVisible={() => {
if (!abortController.signal.aborted) {
abortController.abort();
}
dispatch(setRecoveryPassword(''));
dispatch(setDisplayName(''));
dispatch(setProgress(0));
dispatch(setRecoveryPasswordError(undefined));
dispatch(setDisplayNameError(undefined));
if (
step === AccountRestoration.Loading ||
step === AccountRestoration.Finishing ||
step === AccountRestoration.Finished
) {
dispatch(setAccountRestorationStep(AccountRestoration.RecoveryPassword));
}
}}
callback={() => { callback={() => {
dispatch(setRecoveryPassword('')); dispatch(setRecoveryPassword(''));
dispatch(setDisplayName('')); dispatch(setDisplayName(''));

Loading…
Cancel
Save