fix: small fixes from broken branch as we try to debug

pull/3056/head
William Grant 1 year ago
parent b5781b0f12
commit 5e79ebc239

@ -1,4 +1,3 @@
import { useEffect } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { useMount } from 'react-use'; import { useMount } from 'react-use';
import { SettingsKey } from '../../../data/settings-key'; import { SettingsKey } from '../../../data/settings-key';
@ -17,8 +16,6 @@ import {
import { import {
useDisplayName, useDisplayName,
useDisplayNameError, useDisplayNameError,
useOnboardAccountCreationStep,
useOnboardHexGeneratedPubKey,
useRecoveryPassword, useRecoveryPassword,
} from '../../../state/onboarding/selectors/registration'; } from '../../../state/onboarding/selectors/registration';
import { import {
@ -56,9 +53,7 @@ async function signUp(signUpDetails: RecoverDetails) {
} }
export const CreateAccount = () => { export const CreateAccount = () => {
const step = useOnboardAccountCreationStep();
const recoveryPassword = useRecoveryPassword(); const recoveryPassword = useRecoveryPassword();
const hexGeneratedPubKey = useOnboardHexGeneratedPubKey();
const displayName = useDisplayName(); const displayName = useDisplayName();
const displayNameError = useDisplayNameError(); const displayNameError = useDisplayNameError();
@ -88,12 +83,6 @@ export const CreateAccount = () => {
void generateMnemonicAndKeyPair(); void generateMnemonicAndKeyPair();
}); });
useEffect(() => {
if (step === AccountCreation.DisplayName && hexGeneratedPubKey) {
window.Session.setNewSessionID(hexGeneratedPubKey);
}
}, [step, hexGeneratedPubKey]);
const signUpWithDetails = async () => { const signUpWithDetails = async () => {
if (!(!!displayName && !displayNameError)) { if (!(!!displayName && !displayNameError)) {
return; return;

@ -79,8 +79,6 @@ export const FEATURE_RELEASE_TIMESTAMPS = {
export const ONBOARDING_TIMES = { export const ONBOARDING_TIMES = {
/** 15 seconds */ /** 15 seconds */
RECOVERY_TIMEOUT: 15 * DURATION.SECONDS, RECOVERY_TIMEOUT: 15 * DURATION.SECONDS,
// TODO remove later
// RECOVERY_TIMEOUT: 3 * DURATION.SECONDS,
/** 0.3 seconds */ /** 0.3 seconds */
RECOVERY_FINISHING: 0.3 * DURATION.SECONDS, RECOVERY_FINISHING: 0.3 * DURATION.SECONDS,
/** 0.2 seconds */ /** 0.2 seconds */

@ -62,20 +62,6 @@ const generateKeypair = async (
return sessionGenerateKeyPair(seed); 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. * 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. * @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); 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 mnemonic The mnemonic generated on first app loading and to use for this brand new user
* @param mnemonicLanguage only 'english' is supported * @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( export async function registerSingleDevice(
generatedMnemonic: string, generatedMnemonic: string,
mnemonicLanguage: string, mnemonicLanguage: string,
profileName: string displayName: string
) { ) {
if (!generatedMnemonic) { if (!generatedMnemonic) {
throw new Error('Session always needs a mnemonic. Either generated or given by the user'); 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'); throw new Error('We always needs a profileName');
} }
if (!mnemonicLanguage) { if (!mnemonicLanguage) {
@ -142,7 +128,7 @@ export async function registerSingleDevice(
await setLastProfileUpdateTimestamp(Date.now()); await setLastProfileUpdateTimestamp(Date.now());
const pubKeyString = toHex(identityKeyPair.pubKey); const pubKeyString = toHex(identityKeyPair.pubKey);
await registrationDone(pubKeyString, profileName); await registrationDone(pubKeyString, displayName);
} }
export async function generateMnemonic() { export async function generateMnemonic() {
@ -237,6 +223,6 @@ export async function registrationDone(ourPubkey: string, displayName: string) {
window.inboxStore?.dispatch(userActions.userChanged(user)); window.inboxStore?.dispatch(userActions.userChanged(user));
window?.log?.info('dispatching registration event'); 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'); trigger('registration_done');
} }

Loading…
Cancel
Save