only call sync_apply if sync_get fails with 'no wallet found for this user'
This commit is contained in:
parent
d91b971bfe
commit
517c28a183
3 changed files with 39 additions and 29 deletions
25
dist/bundle.es.js
vendored
25
dist/bundle.es.js
vendored
|
@ -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,17 +994,19 @@ function doGetSync(passedPassword, callback) {
|
|||
}); // call sync_apply to get data to sync
|
||||
// first time sync. use any string for old hash
|
||||
|
||||
lbryRedux.Lbry.sync_apply({
|
||||
password
|
||||
}).then(({
|
||||
hash: walletHash,
|
||||
data: syncApplyData
|
||||
}) => {
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
}).catch(syncApplyError => {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
if (syncAttemptError.message === NO_WALLET_ERROR) {
|
||||
lbryRedux.Lbry.sync_apply({
|
||||
password
|
||||
}).then(({
|
||||
hash: walletHash,
|
||||
data: syncApplyData
|
||||
}) => {
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
}).catch(syncApplyError => {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
23
dist/bundle.js
vendored
23
dist/bundle.js
vendored
|
@ -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,16 +3733,18 @@ function doGetSync(passedPassword, callback) {
|
|||
}); // call sync_apply to get data to sync
|
||||
// first time sync. use any string for old hash
|
||||
|
||||
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
|
||||
password: password
|
||||
}).then(function (_ref) {
|
||||
var walletHash = _ref.hash,
|
||||
syncApplyData = _ref.data;
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
})["catch"](function (syncApplyError) {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
if (syncAttemptError.message === NO_WALLET_ERROR) {
|
||||
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
|
||||
password: password
|
||||
}).then(function (_ref) {
|
||||
var walletHash = _ref.hash,
|
||||
syncApplyData = _ref.data;
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
})["catch"](function (syncApplyError) {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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,14 +180,16 @@ export function doGetSync(passedPassword, callback) {
|
|||
|
||||
// call sync_apply to get data to sync
|
||||
// first time sync. use any string for old hash
|
||||
Lbry.sync_apply({ password })
|
||||
.then(({ hash: walletHash, data: syncApplyData }) => {
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
})
|
||||
.catch(syncApplyError => {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
if (syncAttemptError.message === NO_WALLET_ERROR) {
|
||||
Lbry.sync_apply({ password })
|
||||
.then(({ hash: walletHash, data: syncApplyData }) => {
|
||||
dispatch(doSetSync('', walletHash, syncApplyData, password));
|
||||
handleCallback();
|
||||
})
|
||||
.catch(syncApplyError => {
|
||||
handleCallback(syncApplyError);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue