From 69f9562b016030b481375443f56147ff5e273c0e Mon Sep 17 00:00:00 2001 From: jessop Date: Wed, 10 Jul 2019 20:44:15 -0400 Subject: [PATCH] modifications --- dist/bundle.es.js | 28 ++++++++++------------------ dist/bundle.js | 30 ++++++++++-------------------- src/redux/actions/filtered.js | 12 ++++-------- src/redux/reducers/filtered.js | 15 ++++++--------- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 410b124..a26c62b 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1907,10 +1907,9 @@ function doFetchFilteredOutpoints() { const success = ({ outpoints }) => { - const splitedOutpoints = []; - outpoints.forEach((outpoint, index) => { + const formattedOutpoints = outpoints.map(outpoint => { const [txid, nout] = outpoint.split(':'); - splitedOutpoints[index] = { + return { txid, nout: Number.parseInt(nout, 10) }; @@ -1918,8 +1917,7 @@ function doFetchFilteredOutpoints() { dispatch({ type: FETCH_FILTERED_CONTENT_COMPLETED, data: { - outpoints: splitedOutpoints, - success: true + outpoints: formattedOutpoints } }); }; @@ -1930,8 +1928,7 @@ function doFetchFilteredOutpoints() { dispatch({ type: FETCH_FILTERED_CONTENT_FAILED, data: { - error, - success: false + error } }); }; @@ -2634,33 +2631,28 @@ const blacklistReducer = handleActions({ }, defaultState$5); const defaultState$6 = { - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: undefined, + loading: false, filteredOutpoints: undefined }; const filteredReducer = handleActions({ [FETCH_FILTERED_CONTENT_STARTED]: state => ({ ...state, - fetchingFilteredOutpoints: true + loading: true }), [FETCH_FILTERED_CONTENT_COMPLETED]: (state, action) => { const { - outpoints, - success + outpoints } = action.data; return { ...state, - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, filteredOutpoints: outpoints }; }, [FETCH_FILTERED_CONTENT_FAILED]: (state, action) => { const { - error, - success + error } = action.data; return { ...state, - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, fetchingFilteredOutpointsError: error }; } diff --git a/dist/bundle.js b/dist/bundle.js index 89f2bc5..fb5239a 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -3325,14 +3325,13 @@ function doFetchFilteredOutpoints() { var success = function success(_ref) { var outpoints = _ref.outpoints; - var splitedOutpoints = []; - outpoints.forEach(function (outpoint, index) { + var formattedOutpoints = outpoints.map(function (outpoint) { var _outpoint$split = outpoint.split(':'), _outpoint$split2 = _slicedToArray(_outpoint$split, 2), txid = _outpoint$split2[0], nout = _outpoint$split2[1]; - splitedOutpoints[index] = { + return { txid: txid, nout: Number.parseInt(nout, 10) }; @@ -3340,8 +3339,7 @@ function doFetchFilteredOutpoints() { dispatch({ type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["FETCH_FILTERED_CONTENT_COMPLETED"], data: { - outpoints: splitedOutpoints, - success: true + outpoints: formattedOutpoints } }); }; @@ -3351,8 +3349,7 @@ function doFetchFilteredOutpoints() { dispatch({ type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["FETCH_FILTERED_CONTENT_FAILED"], data: { - error: error, - success: false + error: error } }); }; @@ -4247,30 +4244,23 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope var defaultState = { - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: undefined, + loading: false, filteredOutpoints: undefined }; var filteredReducer = Object(util_redux_utils__WEBPACK_IMPORTED_MODULE_1__["handleActions"])((_handleActions = {}, _defineProperty(_handleActions, constants_action_types__WEBPACK_IMPORTED_MODULE_0__["FETCH_FILTERED_CONTENT_STARTED"], function (state) { return _objectSpread({}, state, { - fetchingFilteredOutpoints: true + loading: true }); }), _defineProperty(_handleActions, constants_action_types__WEBPACK_IMPORTED_MODULE_0__["FETCH_FILTERED_CONTENT_COMPLETED"], function (state, action) { - var _action$data = action.data, - outpoints = _action$data.outpoints, - success = _action$data.success; + var outpoints = action.data.outpoints; return _objectSpread({}, state, { - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, filteredOutpoints: outpoints }); }), _defineProperty(_handleActions, constants_action_types__WEBPACK_IMPORTED_MODULE_0__["FETCH_FILTERED_CONTENT_FAILED"], function (state, action) { - var _action$data2 = action.data, - error = _action$data2.error, - success = _action$data2.success; + var error = action.data.error; return _objectSpread({}, state, { - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, fetchingFilteredOutpointsError: error }); }), _handleActions), defaultState); diff --git a/src/redux/actions/filtered.js b/src/redux/actions/filtered.js index 7d831b0..6e9fdb1 100644 --- a/src/redux/actions/filtered.js +++ b/src/redux/actions/filtered.js @@ -10,18 +10,15 @@ export function doFetchFilteredOutpoints() { }); const success = ({ outpoints }) => { - const splitedOutpoints = []; - - outpoints.forEach((outpoint, index) => { + const formattedOutpoints = outpoints.map(outpoint => { const [txid, nout] = outpoint.split(':'); - - splitedOutpoints[index] = { txid, nout: Number.parseInt(nout, 10) }; + return { txid, nout: Number.parseInt(nout, 10) }; }); + dispatch({ type: ACTIONS.FETCH_FILTERED_CONTENT_COMPLETED, data: { - outpoints: splitedOutpoints, - success: true, + outpoints: formattedOutpoints, }, }); }; @@ -31,7 +28,6 @@ export function doFetchFilteredOutpoints() { type: ACTIONS.FETCH_FILTERED_CONTENT_FAILED, data: { error, - success: false, }, }); }; diff --git a/src/redux/reducers/filtered.js b/src/redux/reducers/filtered.js index 9ba09b5..0214715 100644 --- a/src/redux/reducers/filtered.js +++ b/src/redux/reducers/filtered.js @@ -2,8 +2,7 @@ import * as ACTIONS from 'constants/action_types'; import { handleActions } from 'util/redux-utils'; const defaultState = { - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: undefined, + loading: false, filteredOutpoints: undefined, }; @@ -11,24 +10,22 @@ export const filteredReducer = handleActions( { [ACTIONS.FETCH_FILTERED_CONTENT_STARTED]: state => ({ ...state, - fetchingFilteredOutpoints: true, + loading: true, }), [ACTIONS.FETCH_FILTERED_CONTENT_COMPLETED]: (state, action) => { - const { outpoints, success } = action.data; + const { outpoints } = action.data; return { ...state, - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, filteredOutpoints: outpoints, }; }, [ACTIONS.FETCH_FILTERED_CONTENT_FAILED]: (state, action) => { - const { error, success } = action.data; + const { error } = action.data; return { ...state, - fetchingFilteredOutpoints: false, - fetchingFilteredOutpointsSucceed: success, + loading: false, fetchingFilteredOutpointsError: error, }; },