trigger sync error correctly with locked wallets (#82)

trigger sync error correctly with locked wallets
This commit is contained in:
Sean Yesmunt 2020-01-28 12:31:39 -05:00 committed by GitHub
commit 1932c30a36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 16 deletions

36
dist/bundle.es.js vendored
View file

@ -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);
});
}
});

36
dist/bundle.js vendored
View file

@ -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);
});
}
});

View file

@ -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);
});
}
});