diff --git a/src/js/features/escrow/saga.js b/src/js/features/escrow/saga.js index 603ed42b..03743dee 100644 --- a/src/js/features/escrow/saga.js +++ b/src/js/features/escrow/saga.js @@ -22,6 +22,7 @@ import { WATCH_ESCROW, ESCROW_EVENT_RECEIVED, WATCH_ESCROW_CREATIONS, ESCROW_CREATED_EVENT_RECEIVED, GET_LAST_ACTIVITY, GET_LAST_ACTIVITY_SUCCEEDED, GET_LAST_ACTIVITY_FAILED } from './constants'; import {eventTypes} from './helpers'; +import {ADD_OFFER_SUCCEEDED} from "../metadata/constants"; export function *createEscrow({user, escrow}) { const toSend = Escrow.methods.create( @@ -301,8 +302,21 @@ export function *onWatchEscrowCreations() { yield takeEvery(WATCH_ESCROW_CREATIONS, watchEscrowCreations); } +export function *watchNewOffer({offer, receipt}) { + try { + const newOffer = Object.assign({}, offer, {id: receipt.events.OfferAdded.returnValues.offerId}); + yield put({type: WATCH_ESCROW_CREATIONS, offers: [newOffer]}); + } catch (error) { + console.error(error); + } +} + +export function *onWatchAddOfferSuccess() { + yield takeEvery(ADD_OFFER_SUCCEEDED, watchNewOffer); +} + export default [ fork(onCreateEscrow), fork(onLoadEscrows), fork(onGetEscrow), fork(onReleaseEscrow), fork(onCancelEscrow), fork(onUserRating), fork(onAddUserRating), fork(onRateTx), fork(onPayEscrow), fork(onPayEscrowSignature), fork(onOpenCase), fork(onOpenCaseSignature), fork(onOpenCaseSuccess), - fork(onGetFee), fork(onFundEscrow), fork(onWatchEscrow), fork(onWatchEscrowCreations), fork(onGetEscrowAfterEvent), fork(onGetLastActivity) + fork(onGetFee), fork(onFundEscrow), fork(onWatchEscrow), fork(onWatchEscrowCreations), fork(onGetEscrowAfterEvent), fork(onGetLastActivity), fork(onWatchAddOfferSuccess) ];