diff --git a/src/page/firstRun/index.js b/src/page/firstRun/index.js index 35ce654..1596cb3 100644 --- a/src/page/firstRun/index.js +++ b/src/page/firstRun/index.js @@ -46,7 +46,7 @@ const perform = dispatch => ({ syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), getSync: password => dispatch(doGetSync(password)), checkSync: () => dispatch(doCheckSync()), - setDefaultAccount: () => dispatch(doSetDefaultAccount()), + setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)), notify: data => dispatch(doToast(data)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), }); diff --git a/src/page/firstRun/view.js b/src/page/firstRun/view.js index 62a4ea6..b2995f4 100644 --- a/src/page/firstRun/view.js +++ b/src/page/firstRun/view.js @@ -86,16 +86,25 @@ class FirstRunScreen extends React.PureComponent { this.setState({ showBottomContainer: true }); } else { // password successfully verified - if (NativeModules.UtilityModule) { - NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword); - } - setDefaultAccount(); - setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); + NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword); + setDefaultAccount( + () => { + setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); - // unlock the wallet - Lbry.account_unlock({ password: this.state.walletPassword || '' }) - .then(() => this.closeFinalPage()) - .catch(err => notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })); + // unlock the wallet + Lbry.account_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' }) + .then(() => this.closeFinalPage()) + .catch(err => + notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' }) + ); + }, + err => { + notify({ + message: + 'The account restore operation could not be completed successfully. Please restart the app and try again.', + }); + } + ); } } diff --git a/src/page/verification/index.js b/src/page/verification/index.js index c1d71bd..30dca55 100644 --- a/src/page/verification/index.js +++ b/src/page/verification/index.js @@ -29,7 +29,7 @@ import { } from 'lbryinc'; import { doSetClientSetting } from 'redux/actions/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings'; -import Constants from 'constants'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Verification from './view'; const select = state => ({ @@ -54,13 +54,13 @@ const select = state => ({ const perform = dispatch => ({ addUserEmail: email => dispatch(doUserEmailNew(email)), - addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)), + addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)), getSync: password => dispatch(doGetSync(password)), checkSync: () => dispatch(doCheckSync()), verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)), notify: data => dispatch(doToast(data)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), - setDefaultAccount: () => dispatch(doSetDefaultAccount()), + setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)), setEmailToVerify: email => dispatch(doUserEmailToVerify(email)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), diff --git a/src/page/verification/internal/sync-verify-page.js b/src/page/verification/internal/sync-verify-page.js index cddd8ee..6862733 100644 --- a/src/page/verification/internal/sync-verify-page.js +++ b/src/page/verification/internal/sync-verify-page.js @@ -67,13 +67,24 @@ class SyncVerifyPage extends React.PureComponent { this.state.password ? this.state.password : '' ); } - setDefaultAccount(); - setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); + setDefaultAccount( + () => { + setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); - // unlock the wallet - Lbry.account_unlock({ password: this.state.password ? this.state.password : '' }) - .then(() => navigation.goBack()) - .catch(err => notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })); + // unlock the wallet + Lbry.account_unlock({ password: this.state.password ? this.state.password : '' }) + .then(() => navigation.goBack()) + .catch(err => + notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' }) + ); + }, + err => { + notify({ + message: + 'The account restore operation could not be completed successfully. Please restart the app and try again.', + }); + } + ); } } }