From 1d9dff24d60dc88066e26be2b1c12e09d9f3e8e2 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 6 Jun 2019 13:45:55 -0400 Subject: [PATCH 1/2] feat: watch new offers created --- src/js/features/escrow/saga.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/features/escrow/saga.js b/src/js/features/escrow/saga.js index 603ed42b..ba473112 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) ]; From 87d3501c24f17ada2dc5915ac7926ee60337fb8c Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 6 Jun 2019 14:10:15 -0400 Subject: [PATCH 2/2] fix lint --- src/js/features/escrow/saga.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/features/escrow/saga.js b/src/js/features/escrow/saga.js index ba473112..03743dee 100644 --- a/src/js/features/escrow/saga.js +++ b/src/js/features/escrow/saga.js @@ -304,7 +304,7 @@ export function *onWatchEscrowCreations() { export function *watchNewOffer({offer, receipt}) { try { - const newOffer = Object.assign({}, offer, {id: receipt.events.OfferAdded.returnValues.offerId}) + const newOffer = Object.assign({}, offer, {id: receipt.events.OfferAdded.returnValues.offerId}); yield put({type: WATCH_ESCROW_CREATIONS, offers: [newOffer]}); } catch (error) { console.error(error);