-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
934bdd6
commit bdeb094
Showing
7 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
packages/blockchain-wallet-v4-frontend/src/scenes/ExchangeHistory/selectors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { difference, equals, filter, lift, or, prop } from 'ramda' | ||
import { anyPass, curry, equals, filter, lift, map, prop } from 'ramda' | ||
import { selectors } from 'data' | ||
|
||
const getTradesWithStatus = (trades, status1, status2) => filter(trade => or(equals(prop('status', trade), status1), equals(prop('status', trade), status2)), trades) | ||
const getTradesWithStatus = curry((statuses, trades) => | ||
filter(trade => anyPass(map(equals, statuses))(prop('status', trade)), trades)) | ||
|
||
export const getData = (state) => { | ||
const trades = selectors.core.kvStore.shapeShift.getTrades(state) | ||
const completedTrades = trades.map(t => getTradesWithStatus(t, 'complete', 'resolved')) | ||
const incompleteTrades = lift((t, completed) => difference(t, completed))(trades, completedTrades) | ||
return lift((c, i) => ({ complete: c, incomplete: i }))(completedTrades, incompleteTrades) | ||
const completedTrades = lift(getTradesWithStatus(['complete', 'resolved']))(trades) | ||
const errorTrades = lift(getTradesWithStatus(['error', 'failed']))(trades) | ||
const incompleteTrades = lift(getTradesWithStatus(['no_deposits']))(trades) | ||
return lift((c, i, e) => | ||
({ complete: c, incomplete: i, error: e }))(completedTrades, incompleteTrades, errorTrades) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/blockchain-wallet-v4/src/redux/kvStore/shapeShift/sagaRegister.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
|
||
import { takeLatest } from 'redux-saga/effects' | ||
import { takeEvery, takeLatest } from 'redux-saga/effects' | ||
import * as AT from './actionTypes' | ||
import sagas from './sagas' | ||
|
||
export default ({ api }) => { | ||
const kvStoreShapeshiftSagas = sagas({ api }) | ||
|
||
return function * () { | ||
yield takeEvery(AT.FETCH_SHAPESHIFT_TRADE, kvStoreShapeshiftSagas.fetchShapeshiftTrade) | ||
yield takeLatest(AT.FETCH_METADATA_SHAPESHIFT, kvStoreShapeshiftSagas.fetchMetadataShapeshift) | ||
} | ||
} |