only call sync_apply if sync_get fails with 'no wallet found for this user'

This commit is contained in:
Sean Yesmunt 2020-10-23 21:15:58 -04:00
parent d91b971bfe
commit 517c28a183
3 changed files with 39 additions and 29 deletions

3
dist/bundle.es.js vendored
View file

@ -794,6 +794,7 @@ const doFetchSubCount = claimId => dispatch => {
});
};
const NO_WALLET_ERROR = 'no wallet found for this user';
function doSetDefaultAccount(success, failure) {
return dispatch => {
dispatch({
@ -993,6 +994,7 @@ function doGetSync(passedPassword, callback) {
}); // call sync_apply to get data to sync
// first time sync. use any string for old hash
if (syncAttemptError.message === NO_WALLET_ERROR) {
lbryRedux.Lbry.sync_apply({
password
}).then(({
@ -1005,6 +1007,7 @@ function doGetSync(passedPassword, callback) {
handleCallback(syncApplyError);
});
}
}
});
};
}

3
dist/bundle.js vendored
View file

@ -3535,6 +3535,7 @@ __webpack_require__.r(__webpack_exports__);
var NO_WALLET_ERROR = 'no wallet found for this user';
function doSetDefaultAccount(success, failure) {
return function (dispatch) {
dispatch({
@ -3732,6 +3733,7 @@ function doGetSync(passedPassword, callback) {
}); // call sync_apply to get data to sync
// first time sync. use any string for old hash
if (syncAttemptError.message === NO_WALLET_ERROR) {
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
password: password
}).then(function (_ref) {
@ -3743,6 +3745,7 @@ function doGetSync(passedPassword, callback) {
handleCallback(syncApplyError);
});
}
}
});
};
}

View file

@ -2,6 +2,8 @@ import * as ACTIONS from 'constants/action_types';
import Lbryio from 'lbryio';
import { Lbry, doWalletEncrypt, doWalletDecrypt } from 'lbry-redux';
const NO_WALLET_ERROR = 'no wallet found for this user';
export function doSetDefaultAccount(success, failure) {
return dispatch => {
dispatch({
@ -178,6 +180,7 @@ export function doGetSync(passedPassword, callback) {
// call sync_apply to get data to sync
// first time sync. use any string for old hash
if (syncAttemptError.message === NO_WALLET_ERROR) {
Lbry.sync_apply({ password })
.then(({ hash: walletHash, data: syncApplyData }) => {
dispatch(doSetSync('', walletHash, syncApplyData, password));
@ -187,6 +190,7 @@ export function doGetSync(passedPassword, callback) {
handleCallback(syncApplyError);
});
}
}
});
};
}