feat: restoring an account from seed and fetching seems to work

pull/3056/head
William Grant 2 years ago
parent e0ca888e85
commit 8e41d51632

@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { Provider } from 'react-redux';
import styled from 'styled-components';
import { useMount } from 'react-use';
import { onboardingStore } from '../../state/onboarding/store';
import { SessionTheme } from '../../themes/SessionTheme';
import { setSignInByLinking } from '../../util/storage';
@ -56,9 +56,9 @@ const StyledSessionContent = styled(Flex)`
`;
export const SessionRegistrationView = () => {
useEffect(() => {
useMount(() => {
void setSignInByLinking(false);
}, []);
});
return (
<Provider store={onboardingStore}>

@ -89,7 +89,7 @@ async function signInAndFetchDisplayName(
'configurationMessageReceived',
async (ourPubkey: string, displayName: string) => {
window.Whisper.events.off('configurationMessageReceived');
await setSignInByLinking(true);
await setSignInByLinking(false);
await setSignWithRecoveryPhrase(false);
dispatch(setHexGeneratedPubKey(ourPubkey));
dispatch(setDisplayName(displayName));

@ -409,9 +409,6 @@ export class SwarmPolling {
// we take the lastest config message to create the wrapper in memory
const incomingConfigMessage = allDecryptedConfigMessages.at(-1);
window.log.debug(
`WIP: [SwarmPolling] configMessage: ${JSON.stringify(incomingConfigMessage)}`
);
if (!incomingConfigMessage) {
throw new Error('incomingConfigMessage not found');
}
@ -681,9 +678,6 @@ export class SwarmPolling {
toPollFrom,
UserUtils.getOurPubKeyStrFromCache()
);
window.log.debug(
`WIP: [resultsFromUserProfile] resultsFromUserProfile: ${JSON.stringify(resultsFromUserProfile)}`
);
} catch (e) {
if (e.message === ERROR_CODE_NO_CONNECT) {
if (window.inboxStore?.getState().onionPaths.isOnline) {
@ -709,10 +703,6 @@ export class SwarmPolling {
const userConfigMessagesMerged = flatten(compact(userConfigMessages));
if (userConfigMessagesMerged.length) {
window.log.info(
`[pollOnceForDisplayName] received userConfigMessages count: ${userConfigMessagesMerged.length} for key ${pubkey.key}`
);
const displayName = await this.handleSharedConfigMessages(userConfigMessagesMerged, true);
return displayName;
}

@ -14,7 +14,7 @@ import { NotFoundError } from '../session/utils/errors';
import { LibSessionUtil } from '../session/utils/libsession/libsession_utils';
import { actions as userActions } from '../state/ducks/user';
import { Registration } from './registration';
import { Storage, saveRecoveryPhrase, setLocalPubKey } from './storage';
import { Storage, saveRecoveryPhrase, setLocalPubKey, setSignInByLinking } from './storage';
/**
* Might throw
@ -78,6 +78,7 @@ export async function signInByLinkingDevice(
const identityKeyPair = await generateKeypair(mnemonic, mnemonicLanguage);
await setSignInByLinking(true);
loadingAnimationCallback();
await createAccount(identityKeyPair);
await saveRecoveryPhrase(mnemonic);

@ -113,6 +113,7 @@ export function isSignInByLinking() {
return isByLinking;
}
/** this is a loading state to prevent config sync jobs while we are trying to sign in through link a device. It should be set to false after the linking is complete */
export async function setSignInByLinking(isLinking: boolean) {
await put('is_sign_in_by_linking', isLinking);
}

Loading…
Cancel
Save