From 63acb481824432052819b6e3de4a2ee8a7ec44a0 Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 13 Aug 2020 13:53:49 -0400 Subject: [PATCH] selectors for blocklist objects --- dist/bundle.es.js | 14 ++++++++++++++ dist/bundle.js | 26 ++++++++++++++++++++++++++ src/index.js | 7 +++++-- src/redux/selectors/blacklist.js | 10 ++++++++++ src/redux/selectors/filtered.js | 10 ++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 34d5da2..f60ae6c 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1464,9 +1464,21 @@ const makeSelectFetchingCostInfoForUri = uri => reselect.createSelector(selectFe const selectState$2 = state => state.blacklist || {}; const selectBlackListedOutpoints = reselect.createSelector(selectState$2, state => state.blackListedOutpoints); +const selectBlacklistedOutpointMap = reselect.createSelector(selectBlackListedOutpoints, outpoints => outpoints.reduce((acc, val) => { + const outpoint = `${val.txid}:${val.nout}`; + return { ...acc, + [outpoint]: 1 + }; +}, {})); const selectState$3 = state => state.filtered || {}; const selectFilteredOutpoints = reselect.createSelector(selectState$3, state => state.filteredOutpoints); +const selectFilteredOutpointMap = reselect.createSelector(selectFilteredOutpoints, outpoints => outpoints.reduce((acc, val) => { + const outpoint = `${val.txid}:${val.nout}`; + return { ...acc, + [outpoint]: 1 + }; +}, {})); const selectState$4 = state => state.homepage || {}; @@ -1534,11 +1546,13 @@ exports.makeSelectViewCountForUri = makeSelectViewCountForUri; exports.selectAllCostInfoByUri = selectAllCostInfoByUri; exports.selectAuthToken = selectAuthToken; exports.selectBlackListedOutpoints = selectBlackListedOutpoints; +exports.selectBlacklistedOutpointMap = selectBlacklistedOutpointMap; exports.selectCurrentUploads = selectCurrentUploads; exports.selectFeaturedUris = selectFeaturedUris; exports.selectFetchingCostInfo = selectFetchingCostInfo; exports.selectFetchingFeaturedUris = selectFetchingFeaturedUris; exports.selectFetchingTrendingUris = selectFetchingTrendingUris; +exports.selectFilteredOutpointMap = selectFilteredOutpointMap; exports.selectFilteredOutpoints = selectFilteredOutpoints; exports.selectGetSyncErrorMessage = selectGetSyncErrorMessage; exports.selectGetSyncIsPending = selectGetSyncIsPending; diff --git a/dist/bundle.js b/dist/bundle.js index 11228ee..e6804bf 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -193,9 +193,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var redux_selectors_blacklist__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(35); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectBlackListedOutpoints", function() { return redux_selectors_blacklist__WEBPACK_IMPORTED_MODULE_23__["selectBlackListedOutpoints"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectBlacklistedOutpointMap", function() { return redux_selectors_blacklist__WEBPACK_IMPORTED_MODULE_23__["selectBlacklistedOutpointMap"]; }); + /* harmony import */ var redux_selectors_filtered__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(36); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectFilteredOutpoints", function() { return redux_selectors_filtered__WEBPACK_IMPORTED_MODULE_24__["selectFilteredOutpoints"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectFilteredOutpointMap", function() { return redux_selectors_filtered__WEBPACK_IMPORTED_MODULE_24__["selectFilteredOutpointMap"]; }); + /* harmony import */ var redux_selectors_homepage__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(37); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "selectFeaturedUris", function() { return redux_selectors_homepage__WEBPACK_IMPORTED_MODULE_25__["selectFeaturedUris"]; }); @@ -4537,8 +4541,13 @@ var makeSelectFetchingCostInfoForUri = function makeSelectFetchingCostInfoForUri __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectState", function() { return selectState; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectBlackListedOutpoints", function() { return selectBlackListedOutpoints; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectBlacklistedOutpointMap", function() { return selectBlacklistedOutpointMap; }); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reselect__WEBPACK_IMPORTED_MODULE_0__); +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + var selectState = function selectState(state) { return state.blacklist || {}; @@ -4546,6 +4555,12 @@ var selectState = function selectState(state) { var selectBlackListedOutpoints = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) { return state.blackListedOutpoints; }); +var selectBlacklistedOutpointMap = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectBlackListedOutpoints, function (outpoints) { + return outpoints.reduce(function (acc, val) { + var outpoint = "".concat(val.txid, ":").concat(val.nout); + return _objectSpread({}, acc, _defineProperty({}, outpoint, 1)); + }, {}); +}); /***/ }), /* 36 */ @@ -4555,8 +4570,13 @@ var selectBlackListedOutpoints = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["c __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectState", function() { return selectState; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectFilteredOutpoints", function() { return selectFilteredOutpoints; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "selectFilteredOutpointMap", function() { return selectFilteredOutpointMap; }); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reselect__WEBPACK_IMPORTED_MODULE_0__); +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + var selectState = function selectState(state) { return state.filtered || {}; @@ -4564,6 +4584,12 @@ var selectState = function selectState(state) { var selectFilteredOutpoints = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectState, function (state) { return state.filteredOutpoints; }); +var selectFilteredOutpointMap = Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])(selectFilteredOutpoints, function (outpoints) { + return outpoints.reduce(function (acc, val) { + var outpoint = "".concat(val.txid, ":").concat(val.nout); + return _objectSpread({}, acc, _defineProperty({}, outpoint, 1)); + }, {}); +}); /***/ }), /* 37 */ diff --git a/src/index.js b/src/index.js index 1055be7..d3c8948 100644 --- a/src/index.js +++ b/src/index.js @@ -47,8 +47,11 @@ export { selectAllCostInfoByUri, selectFetchingCostInfo, } from 'redux/selectors/cost_info'; -export { selectBlackListedOutpoints } from 'redux/selectors/blacklist'; -export { selectFilteredOutpoints } from 'redux/selectors/filtered'; +export { + selectBlackListedOutpoints, + selectBlacklistedOutpointMap, +} from 'redux/selectors/blacklist'; +export { selectFilteredOutpoints, selectFilteredOutpointMap } from 'redux/selectors/filtered'; export { selectFeaturedUris, selectFetchingFeaturedUris, diff --git a/src/redux/selectors/blacklist.js b/src/redux/selectors/blacklist.js index 46c5554..bef7721 100644 --- a/src/redux/selectors/blacklist.js +++ b/src/redux/selectors/blacklist.js @@ -6,3 +6,13 @@ export const selectBlackListedOutpoints = createSelector( selectState, state => state.blackListedOutpoints ); + +export const selectBlacklistedOutpointMap = createSelector(selectBlackListedOutpoints, outpoints => + outpoints.reduce((acc, val) => { + const outpoint = `${val.txid}:${val.nout}`; + return { + ...acc, + [outpoint]: 1, + }; + }, {}) +); diff --git a/src/redux/selectors/filtered.js b/src/redux/selectors/filtered.js index 601ca7d..7261f80 100644 --- a/src/redux/selectors/filtered.js +++ b/src/redux/selectors/filtered.js @@ -6,3 +6,13 @@ export const selectFilteredOutpoints = createSelector( selectState, state => state.filteredOutpoints ); + +export const selectFilteredOutpointMap = createSelector(selectFilteredOutpoints, outpoints => + outpoints.reduce((acc, val) => { + const outpoint = `${val.txid}:${val.nout}`; + return { + ...acc, + [outpoint]: 1, + }; + }, {}) +);