Skip to content

Commit

Permalink
feat(Alerts): finish receive currency success alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Jun 22, 2018
1 parent df5d584 commit 1621e6f
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ import * as sagas from './sagas'

export default function * () {
yield takeEvery(AT.alerts.ALERTS_SHOW, sagas.handleTimer)
yield takeEvery(AT.core.webSocket.bitcoin.BTC_PAYMENT_RECEIVED, sagas.bitcoinPaymentReceived)
yield takeEvery(AT.core.webSocket.bch.BCH_PAYMENT_RECEIVED, sagas.bchPaymentReceived)
yield takeEvery(AT.core.webSocket.ethereum.ETH_PAYMENT_RECEIVED, sagas.ethereumPaymentReceived)
}
11 changes: 0 additions & 11 deletions packages/blockchain-wallet-v4-frontend/src/data/alerts/sagas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { delay } from 'redux-saga'
import { call, put } from 'redux-saga/effects'
import * as actions from './actions.js'
import * as C from 'services/AlertService'

const DISMISS_AFTER = 7000

Expand All @@ -10,13 +9,3 @@ export const handleTimer = function * (action) {
yield call(delay, DISMISS_AFTER)
yield put(actions.dismissAlert(id))
}

export const bitcoinPaymentReceived = function * (action) {
yield put(actions.displaySuccess(C.RECEIVE_BTC_SUCCESS))
}
export const bchPaymentReceived = function * (action) {
yield put(actions.displaySuccess(C.RECEIVE_BCH_SUCCESS))
}
export const ethereumPaymentReceived = function * (action) {
yield put(actions.displaySuccess(C.RECEIVE_ETH_SUCCESS))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { takeEvery } from 'redux-saga/effects'
import * as AT from '../../actionTypes'
import sagas from './sagas'

export default () => {
const requestBchSagas = sagas()

return function * () {
yield takeEvery(AT.core.webSocket.bch.PAYMENT_RECEIVED, requestBchSagas.bchPaymentReceived)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { put } from 'redux-saga/effects'
import * as actions from '../../actions.js'
import * as C from 'services/AlertService'

export default () => {
const bchPaymentReceived = function * (action) {
yield put(actions.alerts.displaySuccess(C.RECEIVE_BCH_SUCCESS))
}

return {
bchPaymentReceived
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { takeLatest } from 'redux-saga/effects'
import * as AT from './actionTypes'
import { takeEvery, takeLatest } from 'redux-saga/effects'
import * as requestAT from './actionTypes'
import * as AT from '../../actionTypes'
import sagas from './sagas'

export default () => {
const requestBtcSagas = sagas()

return function * () {
yield takeLatest(AT.REQUEST_BTC_FIRST_STEP_SUBMIT_CLICKED, requestBtcSagas.firstStepSubmitClicked)
yield takeLatest(requestAT.REQUEST_BTC_FIRST_STEP_SUBMIT_CLICKED, requestBtcSagas.firstStepSubmitClicked)
yield takeEvery(AT.core.webSocket.bitcoin.PAYMENT_RECEIVED, requestBtcSagas.btcPaymentReceived)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { put } from 'redux-saga/effects'
import * as actions from '../../actions.js'
import * as C from 'services/AlertService'

export default () => {
const logLocation = 'components/requestBtc/sagas'
Expand All @@ -13,7 +14,12 @@ export default () => {
}
}

const btcPaymentReceived = function * (action) {
yield put(actions.alerts.displaySuccess(C.RECEIVE_BTC_SUCCESS))
}

return {
firstStepSubmitClicked
firstStepSubmitClicked,
btcPaymentReceived
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { takeEvery } from 'redux-saga/effects'
import * as AT from '../../actionTypes'
import sagas from './sagas'

export default () => {
const requestEthSagas = sagas()

return function * () {
yield takeEvery(AT.core.webSocket.ethereum.PAYMENT_RECEIVED, requestEthSagas.ethPaymentReceived)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { put } from 'redux-saga/effects'
import * as actions from '../../actions.js'
import * as C from 'services/AlertService'

export default () => {
const ethPaymentReceived = function * (action) {
yield put(actions.alerts.displaySuccess(C.RECEIVE_ETH_SUCCESS))
}

return {
ethPaymentReceived
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import importBtcAddress from './importBtcAddress/sagaRegister'
import manageAddresses from './manageAddresses/sagaRegister'
import priceChart from './priceChart/sagaRegister'
import priceTicker from './priceTicker/sagaRegister'
import requestBch from './requestBch/sagaRegister'
import requestBtc from './requestBtc/sagaRegister'
import requestEth from './requestEth/sagaRegister'
import sendBch from './sendBch/sagaRegister'
import sendBtc from './sendBtc/sagaRegister'
import sendEth from './sendEth/sagaRegister'
Expand All @@ -28,7 +30,9 @@ export default ({ api, coreSagas }) => function * () {
yield fork(manageAddresses({ api, coreSagas }))
yield fork(priceChart({ coreSagas }))
yield fork(priceTicker({ coreSagas }))
yield fork(requestBch())
yield fork(requestBtc())
yield fork(requestEth())
yield fork(sendBch({ api, coreSagas }))
yield fork(sendBtc({ api, coreSagas }))
yield fork(sendEth({ api, coreSagas }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import importBtcAddress from './importBtcAddress/sagas'
import manageAddresses from './manageAddresses/sagas'
import priceChart from './priceChart/sagas'
import priceTicker from './priceTicker/sagas'
import requestBch from './requestBch/sagas'
import requestBtc from './requestBtc/sagas'
import requestEth from './requestEth/sagas'
import sendBch from './sendBch/sagas'
import sendBtc from './sendBtc/sagas'
import sendEth from './sendEth/sagas'
Expand All @@ -27,7 +29,9 @@ export default ({ api, coreSagas }) => ({
manageAddresses: manageAddresses({ api, coreSagas }),
priceChart: priceChart({ coreSagas }),
priceTicker: priceTicker({ coreSagas }),
requestBch: requestBch(),
requestBtc: requestBtc(),
requestEth: requestEth(),
sendBch: sendBch({ api, coreSagas }),
sendBtc: sendBtc({ api, coreSagas }),
sendEth: sendEth({ api, coreSagas }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export const NEW_ADDRESS_GENERATE_ERROR = 'new_address_generate_error'
export const NEW_WALLET_CREATE_ERROR = 'new_wallet_create_error'
export const NEW_WALLET_CREATE_SUCCESS = 'new_wallet_create_success'
export const PBKDF2_UPDATE_SUCCESS = 'pbkdf2_update_success'
export const RECEIVE_BCH_SUCCESS = 'receive_bch_success'
export const RECEIVE_BTC_SUCCESS = 'receive_btc_success'
export const RECEIVE_ETH_SUCCESS = 'receive_eth_success'
export const REGISTER_ERROR = 'register_error'
export const REGISTER_SUCCESS = 'register_success'
export const RENAME_BCH_WALLET_ERROR = 'rename_bch_wallet_error'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ({ api, bchSocket }) => {
const tx = transactions.payload.transactions[i]
if (tx.hash === message.x.hash) {
if (tx.result > 0) {
yield put(A.webSocket.bch.paymentReceived('Test'))
yield put(A.webSocket.bch.paymentReceived())
}
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default ({ api, btcSocket }) => {
const tx = transactions.payload.transactions[i]
if (tx.hash === message.x.hash) {
if (tx.result > 0) {
yield put(A.webSocket.bitcoin.paymentReceived('You have just received a bitcoin payment.'))
yield put(A.webSocket.bitcoin.paymentReceived())
}
break
}
Expand Down

0 comments on commit 1621e6f

Please sign in to comment.