fix: dont pass redux args to restoration hook

we can use the selectors inside of it
pull/3056/head
William Grant 12 months ago
parent ca0497051b
commit bad21725d9

@ -1,4 +1,3 @@
import { AnyAction } from '@reduxjs/toolkit';
import { isEmpty } from 'lodash';
import { useCallback, useEffect } from 'react';
import { useDispatch } from 'react-redux';
@ -6,31 +5,26 @@ import { ONBOARDING_TIMES } from '../../../session/constants';
import {
AccountRestoration,
setAccountRestorationStep,
setProgress,
} from '../../../state/onboarding/ducks/registration';
import {
useDisplayName,
useOnboardAccountRestorationStep,
useOnboardHexGeneratedPubKey,
useProgress,
} from '../../../state/onboarding/selectors/registration';
import { finishRestore } from '../stages/RestoreAccount';
let interval: NodeJS.Timeout;
type UseRecoveryProgressEffectProps = {
step: AccountRestoration;
progress: number;
setProgress: (progress: number) => AnyAction;
ourPubkey: string;
displayName: string;
};
/**
* Effect to handle the progress rate of the recovery loading animation
* @param step AccountRestoration the onboarding step we are currently on
* @param progress number the progress % of the loading bar
* @param setProgress (progress: number) => AnyAction redux function to set the progress % of the loading bar
* @param ourPubkey: string the public key of the user
* @param displayName: string the display name of the user
*/
export const useRecoveryProgressEffect = (props: UseRecoveryProgressEffectProps) => {
const { step, progress, setProgress, ourPubkey, displayName } = props;
/** Effect to handle the progress rate of the recovery loading animation */
export const useRecoveryProgressEffect = () => {
const totalProgress = 100;
const step = useOnboardAccountRestorationStep();
const ourPubkey = useOnboardHexGeneratedPubKey();
const displayName = useDisplayName();
const progress = useProgress();
const dispatch = useDispatch();
const recoveryComplete = useCallback(async () => {
@ -88,5 +82,5 @@ export const useRecoveryProgressEffect = (props: UseRecoveryProgressEffectProps)
}
return () => clearInterval(interval);
}, [dispatch, displayName, ourPubkey, progress, recoveryComplete, setProgress, step]);
}, [dispatch, displayName, ourPubkey, progress, recoveryComplete, step]);
};

@ -20,7 +20,6 @@ import {
useDisplayName,
useDisplayNameError,
useOnboardAccountRestorationStep,
useOnboardHexGeneratedPubKey,
useProgress,
useRecoveryPassword,
useRecoveryPasswordError,
@ -120,20 +119,13 @@ export const RestoreAccount = () => {
const step = useOnboardAccountRestorationStep();
const recoveryPassword = useRecoveryPassword();
const recoveryPasswordError = useRecoveryPasswordError();
const ourPubkey = useOnboardHexGeneratedPubKey();
const displayName = useDisplayName();
const displayNameError = useDisplayNameError();
const progress = useProgress();
const dispatch = useDispatch();
useRecoveryProgressEffect({
step,
progress,
setProgress,
ourPubkey,
displayName,
});
useRecoveryProgressEffect();
const recoverAndFetchDisplayName = async () => {
if (!(!!recoveryPassword && !recoveryPasswordError)) {

Loading…
Cancel
Save