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 { 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;

@ -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 */

@ -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');
}

Loading…
Cancel
Save