diff --git a/static/app-strings.json b/static/app-strings.json index eb66cc53a..45b6db19b 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1307,5 +1307,6 @@ "Getting your profiles...": "Getting your profiles...", "Enabling sync will switch to your cloud profile.": "Enabling sync will switch to your cloud profile.", "Disabling sync will switch to your local profile.": "Disabling sync will switch to your local profile.", + "Something went wrong...": "Something went wrong...", "--end--": "--end--" } diff --git a/ui/component/syncEnableFlow/view.jsx b/ui/component/syncEnableFlow/view.jsx index 3c12ba2c3..99f0b1854 100644 --- a/ui/component/syncEnableFlow/view.jsx +++ b/ui/component/syncEnableFlow/view.jsx @@ -46,7 +46,6 @@ function SyncEnableFlow(props: Props) { const [step, setStep] = React.useState(INITIAL); const [prefDict, setPrefDict]: [any, (any) => void] = React.useState(); - const [password, setPassword] = React.useState(''); const [error, setError] = React.useState(); const handleSyncToggle = async () => { @@ -116,30 +115,29 @@ function SyncEnableFlow(props: Props) { } }, [mode]); - React.useEffect(() => { - getSavedPassword() - .then(pw => setPassword(pw || '')) - .catch(e => { - setError(e && e.message ? e.message : e); - }); - }, []); - React.useEffect(() => { if (step === FETCH_FOR_ENABLE) { - getSync(password, (e, hasChanged) => { - if (e) { + getSavedPassword() + .then(pw => { + getSync(pw, (e, hasChanged) => { + if (e) { + setStep(ERROR); + setError(e && e.message ? e.message : e); + } else { + Lbry.preference_get().then(result => { + const prefs = {}; + if (result[SHARED_KEY]) prefs[SHARED_KEY] = result[SHARED_KEY]; + if (result[LOCAL_KEY]) prefs[LOCAL_KEY] = result[LOCAL_KEY]; + setPrefDict(prefs); + setStep(CONFIRM); + }); + } + }); + }) + .catch(e => { setStep(ERROR); setError(e && e.message ? e.message : e); - } else { - Lbry.preference_get().then(result => { - const prefs = {}; - if (result[SHARED_KEY]) prefs[SHARED_KEY] = result[SHARED_KEY]; - if (result[LOCAL_KEY]) prefs[LOCAL_KEY] = result[LOCAL_KEY]; - setPrefDict(prefs); - setStep(CONFIRM); - }); - } - }); + }); } if (step === FETCH_FOR_DISABLE) { Lbry.preference_get().then(result => { @@ -150,7 +148,7 @@ function SyncEnableFlow(props: Props) { setStep(CONFIRM); }); } - }, [step, setPrefDict, setStep, password]); + }, [step, setPrefDict, setStep]); if (getSyncPending) { return (