fix: destructure args in sign in methods

cleaned up logging
pull/3056/head
William Grant 1 year ago
parent c1a961477e
commit ca0497051b

@ -50,7 +50,6 @@ export async function finishRestore(pubkey: string, displayName: string) {
await setSignWithRecoveryPhrase(true); await setSignWithRecoveryPhrase(true);
await registrationDone(pubkey, displayName); await registrationDone(pubkey, displayName);
window.log.debug(`WIP: [onboarding] restore account: logging in for ${displayName}`);
trigger('openInbox'); trigger('openInbox');
} }
@ -58,9 +57,11 @@ export async function finishRestore(pubkey: string, displayName: string) {
* This will try to sign in with the user recovery password. * This will try to sign in with the user recovery password.
* If no ConfigurationMessage is received within ONBOARDING_RECOVERY_TIMEOUT, the user will be asked to enter a display name. * If no ConfigurationMessage is received within ONBOARDING_RECOVERY_TIMEOUT, the user will be asked to enter a display name.
*/ */
async function signInAndFetchDisplayName(args: AccountRestoreDetails) { async function signInAndFetchDisplayName({
const { recoveryPassword, dispatch, abortSignal } = args; recoveryPassword,
dispatch,
abortSignal,
}: AccountRestoreDetails) {
try { try {
await resetRegistration(); await resetRegistration();
const promiseLink = signInByLinkingDevice(recoveryPassword, 'english', abortSignal); const promiseLink = signInByLinkingDevice(recoveryPassword, 'english', abortSignal);
@ -90,9 +91,11 @@ async function signInAndFetchDisplayName(args: AccountRestoreDetails) {
* Ask for a display name, as we will drop incoming ConfigurationMessages if any are saved on the swarm. * Ask for a display name, as we will drop incoming ConfigurationMessages if any are saved on the swarm.
* We will handle a ConfigurationMessage * We will handle a ConfigurationMessage
*/ */
async function signInWithNewDisplayName(args: AccountRestoreDetails) { async function signInWithNewDisplayName({
const { displayName, recoveryPassword, dispatch } = args; displayName,
recoveryPassword,
dispatch,
}: AccountRestoreDetails) {
try { try {
const validDisplayName = displayNameIsValid(displayName); const validDisplayName = displayNameIsValid(displayName);
@ -139,9 +142,6 @@ export const RestoreAccount = () => {
const abortController = new AbortController(); const abortController = new AbortController();
try { try {
window.log.debug(
`WIP: [onboarding] restore account: recoverAndFetchDisplayName() is starting recoveryPassword: ${recoveryPassword}`
);
dispatch(setProgress(0)); dispatch(setProgress(0));
dispatch(setAccountRestorationStep(AccountRestoration.Loading)); dispatch(setAccountRestorationStep(AccountRestoration.Loading));
await signInAndFetchDisplayName({ await signInAndFetchDisplayName({
@ -155,8 +155,8 @@ export const RestoreAccount = () => {
if (!abortController.signal.aborted) { if (!abortController.signal.aborted) {
abortController.abort(); abortController.abort();
} }
window.log.debug( window.log.error(
`WIP: [onboarding] restore account: We failed when fetching a display name, so we will enter it manually. Error: ${e.message || e} ` `[onboarding] restore account: Failed to fetch a display name, so we will have to enter it manually. Error: ${e.message || e} `
); );
return; return;
} }
@ -168,9 +168,6 @@ export const RestoreAccount = () => {
} else { } else {
dispatch(setRecoveryPasswordError(window.i18n('recoveryPasswordErrorMessageGeneric'))); dispatch(setRecoveryPasswordError(window.i18n('recoveryPasswordErrorMessageGeneric')));
} }
window.log.debug(
`WIP: [onboarding] restore account: there is a problem with the display name. Error: ${e.message || e}`
);
dispatch(setAccountRestorationStep(AccountRestoration.RecoveryPassword)); dispatch(setAccountRestorationStep(AccountRestoration.RecoveryPassword));
} }
}; };
@ -181,17 +178,14 @@ export const RestoreAccount = () => {
} }
try { try {
window.log.debug(
`WIP: [onboarding] restore account: recoverAndEnterDisplayName() is starting recoveryPassword: ${recoveryPassword} displayName: ${displayName}`
);
await signInWithNewDisplayName({ await signInWithNewDisplayName({
displayName, displayName,
recoveryPassword, recoveryPassword,
dispatch, dispatch,
}); });
} catch (e) { } catch (e) {
window.log.debug( window.log.error(
`WIP: [onboarding] restore account: restoration with new display name failed! Error: ${e.message || e}` `[onboarding] restore account: Failed with new display name! Error: ${e.message || e}`
); );
dispatch(setAccountRestorationStep(AccountRestoration.DisplayName)); dispatch(setAccountRestorationStep(AccountRestoration.DisplayName));
dispatch(setDisplayNameError(e.message || String(e))); dispatch(setDisplayNameError(e.message || String(e)));

Loading…
Cancel
Save