diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 3591283..6238c62 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -2628,8 +2628,18 @@ function doGetSync(passedPassword, callback) { return lbryRedux.Lbry.wallet_unlock({ password }); + } // Wallet is already unlocked + + + return true; + }).then(isUnlocked => { + if (isUnlocked) { + return lbryRedux.Lbry.sync_hash(); } - }).then(() => lbryRedux.Lbry.sync_hash()).then(hash => Lbryio.call('sync', 'get', { + + data.unlockFailed = true; + throw new Error(); + }).then(hash => Lbryio.call('sync', 'get', { hash }, 'post')).then(response => { const syncHash = response.hash; @@ -2669,8 +2679,24 @@ function doGetSync(passedPassword, callback) { data }); handleCallback(); - }).catch(() => { - if (data.hasSyncedWallet) { + }).catch(syncAttemptError => { + if (data.unlockFailed) { + dispatch({ + type: GET_SYNC_FAILED, + data: { + error: syncAttemptError + } + }); + + if (password !== '') { + dispatch({ + type: SYNC_APPLY_BAD_PASSWORD + }); + } + + handleCallback(syncAttemptError); + return; + } else if (data.hasSyncedWallet) { const error = 'Error getting synced wallet'; dispatch({ type: GET_SYNC_FAILED, @@ -2707,8 +2733,8 @@ function doGetSync(passedPassword, callback) { }) => { dispatch(doSetSync('', walletHash, syncApplyData, password)); handleCallback(); - }).catch(error => { - handleCallback(error); + }).catch(syncApplyError => { + handleCallback(syncApplyError); }); } }); diff --git a/dist/bundle.js b/dist/bundle.js index 2834354..bd372c2 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -6396,9 +6396,17 @@ function doGetSync(passedPassword, callback) { return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].wallet_unlock({ password: password }); + } // Wallet is already unlocked + + + return true; + }).then(function (isUnlocked) { + if (isUnlocked) { + return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_hash(); } - }).then(function () { - return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_hash(); + + data.unlockFailed = true; + throw new Error(); }).then(function (hash) { return lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].call('sync', 'get', { hash: hash @@ -6439,8 +6447,24 @@ function doGetSync(passedPassword, callback) { data: data }); handleCallback(); - })["catch"](function () { - if (data.hasSyncedWallet) { + })["catch"](function (syncAttemptError) { + if (data.unlockFailed) { + dispatch({ + type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_FAILED"], + data: { + error: syncAttemptError + } + }); + + if (password !== '') { + dispatch({ + type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SYNC_APPLY_BAD_PASSWORD"] + }); + } + + handleCallback(syncAttemptError); + return; + } else if (data.hasSyncedWallet) { var error = 'Error getting synced wallet'; dispatch({ type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_FAILED"], @@ -6476,8 +6500,8 @@ function doGetSync(passedPassword, callback) { syncApplyData = _ref.data; dispatch(doSetSync('', walletHash, syncApplyData, password)); handleCallback(); - })["catch"](function (error) { - handleCallback(error); + })["catch"](function (syncApplyError) { + handleCallback(syncApplyError); }); } }); diff --git a/src/redux/actions/sync.js b/src/redux/actions/sync.js index 54f8c25..f4e75c2 100644 --- a/src/redux/actions/sync.js +++ b/src/redux/actions/sync.js @@ -102,8 +102,17 @@ export function doGetSync(passedPassword, callback) { if (status.is_locked) { return Lbry.wallet_unlock({ password }); } + + // Wallet is already unlocked + return true; + }) + .then(isUnlocked => { + if (isUnlocked) { + return Lbry.sync_hash(); + } + data.unlockFailed = true; + throw new Error(); }) - .then(() => Lbry.sync_hash()) .then(hash => Lbryio.call('sync', 'get', { hash }, 'post')) .then(response => { const syncHash = response.hash; @@ -132,8 +141,16 @@ export function doGetSync(passedPassword, callback) { dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data }); handleCallback(); }) - .catch(() => { - if (data.hasSyncedWallet) { + .catch(syncAttemptError => { + if (data.unlockFailed) { + dispatch({ type: ACTIONS.GET_SYNC_FAILED, data: { error: syncAttemptError } }); + + if (password !== '') { + dispatch({ type: ACTIONS.SYNC_APPLY_BAD_PASSWORD }); + } + + handleCallback(syncAttemptError); + } else if (data.hasSyncedWallet) { const error = 'Error getting synced wallet'; dispatch({ type: ACTIONS.GET_SYNC_FAILED, @@ -164,8 +181,8 @@ export function doGetSync(passedPassword, callback) { dispatch(doSetSync('', walletHash, syncApplyData, password)); handleCallback(); }) - .catch(error => { - handleCallback(error); + .catch(syncApplyError => { + handleCallback(syncApplyError); }); } });