diff --git a/src/js/features/escrow/reducer.js b/src/js/features/escrow/reducer.js index f0c43539..5c614fbc 100644 --- a/src/js/features/escrow/reducer.js +++ b/src/js/features/escrow/reducer.js @@ -19,7 +19,6 @@ import merge from 'merge'; const DEFAULT_STATE = { escrows: {}, createEscrowStatus: States.none, - cancelStatus: States.none, rateStatus: States.none, fee: '0', newEscrow: null, @@ -164,23 +163,23 @@ function reducer(state = DEFAULT_STATE, action) { fee: action.fee }; case CANCEL_ESCROW: + escrowsClone[escrowId].cancelStatus = States.pending; return { ...state, - cancelStatus: States.pending + escrows: escrowsClone }; - case CANCEL_ESCROW_SUCCEEDED: - { - escrowsClone[escrowId].status = escrowStatus.CANCELED; - return { - ...state, - escrows: escrowsClone, - cancelStatus: States.success - }; - } - case CANCEL_ESCROW_FAILED: + case CANCEL_ESCROW_SUCCEEDED: { + escrowsClone[escrowId].cancelStatus = States.success; + escrowsClone[escrowId].status = escrowStatus.CANCELED; + return { + ...state, + escrows: escrowsClone + }; + } + case CANCEL_ESCROW_FAILED: + escrowsClone[escrowId].cancelStatus = States.failed; return { ...state, - cancelStatus: States.failed, escrows: escrowsClone }; case RATE_TRANSACTION: @@ -255,7 +254,8 @@ function reducer(state = DEFAULT_STATE, action) { createEscrowStatus: States.none, payStatus: States.none, releaseStatus: States.none, - rateStatus: States.none + rateStatus: States.none, + cancelStatus: States.none }; return { ...state, diff --git a/src/js/features/escrow/selectors.js b/src/js/features/escrow/selectors.js index 527e8abd..ffb412ec 100644 --- a/src/js/features/escrow/selectors.js +++ b/src/js/features/escrow/selectors.js @@ -7,8 +7,6 @@ const unimportantStates = [tradeStates.canceled, tradeStates.expired, tradeState export const getCreateEscrowStatus = state => state.escrow.createEscrowStatus; -export const getCancelEscrowStatus = state => state.escrow.cancelStatus; - export const getCreateEscrowId = state => state.escrow.createEscrowId; export const getRatingStatus = state => state.escrow.rateStatus; diff --git a/src/js/pages/Escrow/index.jsx b/src/js/pages/Escrow/index.jsx index 2dc89b71..1fca547a 100644 --- a/src/js/pages/Escrow/index.jsx +++ b/src/js/pages/Escrow/index.jsx @@ -205,7 +205,6 @@ Escrow.propTypes = { releaseEscrow: PropTypes.func, rateStatus: PropTypes.string, payEscrow: PropTypes.func, - cancelStatus: PropTypes.string, approvalTxHash: PropTypes.string, cancelEscrow: PropTypes.func, cancelDispute: PropTypes.func, @@ -218,16 +217,16 @@ Escrow.propTypes = { }; const mapStateToProps = (state, props) => { - const cancelStatus = escrow.selectors.getCancelEscrowStatus(state); const approvalLoading = approval.selectors.isLoading(state); const arbitrationLoading = arbitration.selectors.isLoading(state); const ratingStatus = escrow.selectors.getRatingStatus(state); const escrowId = props.match.params.id.toString(); + const theEscrow = escrow.selectors.getEscrowById(state, escrowId); return { address: network.selectors.getAddress(state) || "", escrowId: escrowId, - escrow: escrow.selectors.getEscrowById(state, escrowId), + escrow: theEscrow, arbitration: arbitration.selectors.getArbitration(state) || {}, fee: escrow.selectors.getFee(state), sntAllowance: approval.selectors.getSNTAllowance(state), @@ -235,10 +234,9 @@ const mapStateToProps = (state, props) => { approvalTxHash: approval.selectors.txHash(state), approvalError: approval.selectors.error(state), tokens: network.selectors.getTokens(state), - loading: cancelStatus === States.pending || ratingStatus === States.pending || approvalLoading || arbitrationLoading, + loading: (theEscrow && theEscrow.cancelStatus === States.pending) || ratingStatus === States.pending || approvalLoading || arbitrationLoading, rateStatus: escrow.selectors.getRatingStatus(state), - escrowEvents: events.selectors.getEscrowEvents(state), - cancelStatus + escrowEvents: events.selectors.getEscrowEvents(state) }; };