Merge pull request #1739 from lbryio/shapeshift-fix
Handle LBC unavailable error from ShapeShift without breaking the app
This commit is contained in:
commit
5cd70d5680
4 changed files with 15 additions and 6 deletions
|
@ -56,7 +56,7 @@ class ActiveShapeShift extends React.PureComponent<Props> {
|
|||
}
|
||||
}
|
||||
|
||||
continousFetch: ?number;
|
||||
continousFetch: ?IntervalID;
|
||||
|
||||
render() {
|
||||
const {
|
||||
|
@ -135,8 +135,8 @@ class ActiveShapeShift extends React.PureComponent<Props> {
|
|||
{shiftState === statuses.NO_DEPOSITS &&
|
||||
shiftReturnAddress && (
|
||||
<div className="help">
|
||||
If the transaction doesn't go through, ShapeShift will return your {shiftCoinType}{' '}
|
||||
back to {shiftReturnAddress}
|
||||
{__("If the transaction doesn't go through, ShapeShift will return your")}{' '}
|
||||
{shiftCoinType} {__('back to')} {shiftReturnAddress}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
export const NO_DEPOSITS = 'no_deposits';
|
||||
export const RECEIVED = 'received';
|
||||
export const COMPLETE = 'complete';
|
||||
export const AVAILABLE = 'available';
|
||||
export const UNAVAILABLE = 'unavailable';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import Promise from 'bluebird';
|
||||
import * as SHAPESHIFT_STATUSES from 'constants/shape_shift';
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
import { coinRegexPatterns } from 'util/shape_shift';
|
||||
import type {
|
||||
|
@ -65,9 +66,15 @@ export const shapeShiftInit = () => (dispatch: Dispatch): ThunkAction => {
|
|||
return shapeShift
|
||||
.coinsAsync()
|
||||
.then(coinData => {
|
||||
if (coinData.LBC.status === SHAPESHIFT_STATUSES.UNAVAILABLE) {
|
||||
return dispatch({
|
||||
type: ACTIONS.GET_SUPPORTED_COINS_FAIL,
|
||||
});
|
||||
}
|
||||
|
||||
let supportedCoins = [];
|
||||
Object.keys(coinData).forEach(symbol => {
|
||||
if (coinData[symbol].status === 'available') {
|
||||
if (coinData[symbol].status === SHAPESHIFT_STATUSES.UNAVAILABLE) {
|
||||
supportedCoins.push(coinData[symbol]);
|
||||
}
|
||||
});
|
||||
|
@ -81,7 +88,7 @@ export const shapeShiftInit = () => (dispatch: Dispatch): ThunkAction => {
|
|||
type: ACTIONS.GET_SUPPORTED_COINS_SUCCESS,
|
||||
data: supportedCoins,
|
||||
});
|
||||
dispatch(getCoinStats(supportedCoins[0]));
|
||||
return dispatch(getCoinStats(supportedCoins[0]));
|
||||
})
|
||||
.catch(err => dispatch({ type: ACTIONS.GET_SUPPORTED_COINS_FAIL, data: err }));
|
||||
};
|
||||
|
|
|
@ -117,7 +117,7 @@ export default handleActions(
|
|||
[ACTIONS.GET_SUPPORTED_COINS_FAIL]: (state: ShapeShiftState): ShapeShiftState => ({
|
||||
...state,
|
||||
loading: false,
|
||||
error: 'Error getting available coins',
|
||||
error: __('There was an error. Please try again later.'),
|
||||
}),
|
||||
|
||||
[ACTIONS.GET_COIN_STATS_START]: (
|
||||
|
|
Loading…
Reference in a new issue