From 5e79ebc2391d78231bfe01fc68cf0fc68a7c7b01 Mon Sep 17 00:00:00 2001 From: William Grant Date: Tue, 26 Mar 2024 13:58:34 +1100 Subject: [PATCH] fix: small fixes from broken branch as we try to debug --- .../registration/stages/CreateAccount.tsx | 11 -------- ts/session/constants.ts | 2 -- ts/util/accountManager.ts | 26 +++++-------------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/ts/components/registration/stages/CreateAccount.tsx b/ts/components/registration/stages/CreateAccount.tsx index 8dd15472f..80c7402dc 100644 --- a/ts/components/registration/stages/CreateAccount.tsx +++ b/ts/components/registration/stages/CreateAccount.tsx @@ -1,4 +1,3 @@ -import { useEffect } from 'react'; import { useDispatch } from 'react-redux'; import { useMount } from 'react-use'; import { SettingsKey } from '../../../data/settings-key'; @@ -17,8 +16,6 @@ import { import { useDisplayName, useDisplayNameError, - useOnboardAccountCreationStep, - useOnboardHexGeneratedPubKey, useRecoveryPassword, } from '../../../state/onboarding/selectors/registration'; import { @@ -56,9 +53,7 @@ async function signUp(signUpDetails: RecoverDetails) { } export const CreateAccount = () => { - const step = useOnboardAccountCreationStep(); const recoveryPassword = useRecoveryPassword(); - const hexGeneratedPubKey = useOnboardHexGeneratedPubKey(); const displayName = useDisplayName(); const displayNameError = useDisplayNameError(); @@ -88,12 +83,6 @@ export const CreateAccount = () => { void generateMnemonicAndKeyPair(); }); - useEffect(() => { - if (step === AccountCreation.DisplayName && hexGeneratedPubKey) { - window.Session.setNewSessionID(hexGeneratedPubKey); - } - }, [step, hexGeneratedPubKey]); - const signUpWithDetails = async () => { if (!(!!displayName && !displayNameError)) { return; diff --git a/ts/session/constants.ts b/ts/session/constants.ts index 18b322d0b..d5a139eaa 100644 --- a/ts/session/constants.ts +++ b/ts/session/constants.ts @@ -79,8 +79,6 @@ export const FEATURE_RELEASE_TIMESTAMPS = { export const ONBOARDING_TIMES = { /** 15 seconds */ RECOVERY_TIMEOUT: 15 * DURATION.SECONDS, - // TODO remove later - // RECOVERY_TIMEOUT: 3 * DURATION.SECONDS, /** 0.3 seconds */ RECOVERY_FINISHING: 0.3 * DURATION.SECONDS, /** 0.2 seconds */ diff --git a/ts/util/accountManager.ts b/ts/util/accountManager.ts index a4b1b7b54..fd19f9de0 100644 --- a/ts/util/accountManager.ts +++ b/ts/util/accountManager.ts @@ -62,20 +62,6 @@ const generateKeypair = async ( return sessionGenerateKeyPair(seed); }; -/** - * Sign in with a recovery password. We won't try to recover an existing profile name - * @param mnemonic the mnemonic the user duly saved in a safe place. We will restore his sessionID based on this. - * @param mnemonicLanguage 'english' only is supported - * @param profileName the displayName to use for this user - */ -export async function signInWithRecovery( - mnemonic: string, - mnemonicLanguage: string, - profileName: string -) { - return registerSingleDevice(mnemonic, mnemonicLanguage, profileName); -} - /** * Sign in with a recovery password and try to recover display name and avatar from the first encountered configuration message. * @param mnemonic the mnemonic the user duly saved in a safe place. We will restore his sessionID based on this. @@ -115,20 +101,20 @@ export async function signInByLinkingDevice( trigger(configurationMessageReceived, displayName, pubKeyString); } /** - * This signs up a new user account. User has no recovery and does not try to link a device + * This registers a user account. If a user recovery fails and does not try to link a device it can also be used * @param mnemonic The mnemonic generated on first app loading and to use for this brand new user * @param mnemonicLanguage only 'english' is supported - * @param profileName the display name to register, character limit is MAX_NAME_LENGTH_BYTES + * @param displayName the display name to register, character limit is MAX_NAME_LENGTH_BYTES */ export async function registerSingleDevice( generatedMnemonic: string, mnemonicLanguage: string, - profileName: string + displayName: string ) { if (!generatedMnemonic) { throw new Error('Session always needs a mnemonic. Either generated or given by the user'); } - if (!profileName) { + if (!displayName) { throw new Error('We always needs a profileName'); } if (!mnemonicLanguage) { @@ -142,7 +128,7 @@ export async function registerSingleDevice( await setLastProfileUpdateTimestamp(Date.now()); const pubKeyString = toHex(identityKeyPair.pubKey); - await registrationDone(pubKeyString, profileName); + await registrationDone(pubKeyString, displayName); } export async function generateMnemonic() { @@ -237,6 +223,6 @@ export async function registrationDone(ourPubkey: string, displayName: string) { window.inboxStore?.dispatch(userActions.userChanged(user)); window?.log?.info('dispatching registration event'); - // this will make the poller start fetching messages, needed to find a configuration message + // this will make the poller start fetching messages trigger('registration_done'); }