unlock after sync apply

This commit is contained in:
Akinwale Ariwodola 2019-09-06 16:11:47 +01:00
parent ced1056596
commit 894b34fd57
4 changed files with 39 additions and 19 deletions

View file

@ -46,7 +46,7 @@ const perform = dispatch => ({
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
}); });

View file

@ -86,16 +86,25 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true }); this.setState({ showBottomContainer: true });
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) { NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword); setDefaultAccount(
} () => {
setDefaultAccount(); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet // unlock the wallet
Lbry.account_unlock({ password: this.state.walletPassword || '' }) Lbry.account_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' })
.then(() => this.closeFinalPage()) .then(() => this.closeFinalPage())
.catch(err => notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })); .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.',
});
}
);
} }
} }

View file

@ -29,7 +29,7 @@ import {
} from 'lbryinc'; } from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/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'; import Verification from './view';
const select = state => ({ const select = state => ({
@ -54,13 +54,13 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)), 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)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)), verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)), setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),

View file

@ -67,13 +67,24 @@ class SyncVerifyPage extends React.PureComponent {
this.state.password ? this.state.password : '' this.state.password ? this.state.password : ''
); );
} }
setDefaultAccount(); setDefaultAccount(
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); () => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet // unlock the wallet
Lbry.account_unlock({ password: this.state.password ? this.state.password : '' }) Lbry.account_unlock({ password: this.state.password ? this.state.password : '' })
.then(() => navigation.goBack()) .then(() => navigation.goBack())
.catch(err => notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })); .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.',
});
}
);
} }
} }
} }