diff --git a/package.json b/package.json index 6e2da33..db8ae7b 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-thunk": "^2.2.0", + "reselect": "^4.0.0", "whatwg-fetch": "^3.0.0" }, "devDependencies": { diff --git a/src/components/Proxies.js b/src/components/Proxies.js index 2303baf..f6d7caf 100644 --- a/src/components/Proxies.js +++ b/src/components/Proxies.js @@ -13,11 +13,11 @@ const th = cx(s0.row, s0.th, 'border-bottom'); import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { getProxies, fetchProxies, requestDelayAll } from 'd/proxies'; +import { getUserProxies, fetchProxies, requestDelayAll } from 'd/proxies'; function mapStateToProps(s) { return { - proxies: getProxies(s) + proxies: getUserProxies(s) }; } diff --git a/src/ducks/proxies.js b/src/ducks/proxies.js index 46ae18f..a82fec2 100644 --- a/src/ducks/proxies.js +++ b/src/ducks/proxies.js @@ -1,9 +1,21 @@ 'use strict'; +import { createSelector } from 'reselect'; import * as proxiesAPI from 'a/proxies'; +const ProxyTypeBuiltin = ['DIRECT', 'GLOBAL', 'REJECT']; + export const getProxies = s => s.proxies.proxies; export const getDelay = s => s.proxies.delay; +export const getUserProxies = createSelector(getProxies, proxies => { + let o = {}; + for (const prop in proxies) { + if (ProxyTypeBuiltin.indexOf(prop) < 0) { + o[prop] = proxies[prop]; + } + } + return o; +}); const CompletedFetchProxies = 'proxies/CompletedFetchProxies'; const OptimisticSwitchProxy = 'proxies/OptimisticSwitchProxy'; diff --git a/yarn.lock b/yarn.lock index 39f2be3..5655f9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6952,6 +6952,11 @@ require-uncached@^1.0.3: caller-path "^0.1.0" resolve-from "^1.0.0" +reselect@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7" + integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA== + resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"