From 112ffe669613361e6cb69004d289e5936c75f444 Mon Sep 17 00:00:00 2001 From: jessopb <36554050+jessopb@users.noreply.github.com> Date: Tue, 16 Jul 2019 23:32:29 -0400 Subject: [PATCH] Filter preview (#2621) * discovery previews use filter api * updates lbryinc * refactor --- package.json | 2 +- src/ui/component/claimPreview/index.js | 3 ++- src/ui/component/claimPreview/view.jsx | 18 +++++++++++------- src/ui/index.jsx | 9 ++++++++- src/ui/reducers.js | 11 ++++++++++- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 176205f9c..968dbaa06 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-redux": "lbryio/lbry-redux#bb82aed61a5569e565daa784eb25fc1d639c0c22", - "lbryinc": "lbryio/lbryinc#43d382d9b74d396a581a74d87e4c53105e04f845", + "lbryinc": "lbryio/lbryinc#69f9562b016030b481375443f56147ff5e273c0e", "lint-staged": "^7.0.2", "localforage": "^1.7.1", "lodash-es": "^4.17.14", diff --git a/src/ui/component/claimPreview/index.js b/src/ui/component/claimPreview/index.js index 6d08b46e0..96bcfdc89 100644 --- a/src/ui/component/claimPreview/index.js +++ b/src/ui/component/claimPreview/index.js @@ -9,7 +9,7 @@ import { makeSelectTitleForUri, makeSelectClaimIsNsfw, } from 'lbry-redux'; -import { selectBlackListedOutpoints } from 'lbryinc'; +import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; import { selectShowNsfw } from 'redux/selectors/settings'; import ClaimPreview from './view'; @@ -23,6 +23,7 @@ const select = (state, props) => ({ title: makeSelectTitleForUri(props.uri)(state), nsfw: makeSelectClaimIsNsfw(props.uri)(state), blackListedOutpoints: selectBlackListedOutpoints(state), + filteredOutpoints: selectFilteredOutpoints(state), }); const perform = dispatch => ({ diff --git a/src/ui/component/claimPreview/view.jsx b/src/ui/component/claimPreview/view.jsx index 4cae67543..8da045d10 100644 --- a/src/ui/component/claimPreview/view.jsx +++ b/src/ui/component/claimPreview/view.jsx @@ -33,6 +33,10 @@ type Props = { txid: string, nout: number, }>, + filteredOutpoints: Array<{ + txid: string, + nout: number, + }>, }; function ClaimPreview(props: Props) { @@ -51,6 +55,7 @@ function ClaimPreview(props: Props) { placeholder, type, blackListedOutpoints, + filteredOutpoints, } = props; const haventFetched = claim === undefined; const abandoned = !isResolvingUri && !claim && !placeholder; @@ -60,14 +65,13 @@ function ClaimPreview(props: Props) { let shouldHide = abandoned || (!claimIsMine && obscureNsfw && nsfw); // This will be replaced once blocking is done at the wallet server level + if (claim && !shouldHide && blackListedOutpoints) { - for (let i = 0; i < blackListedOutpoints.length; i += 1) { - const outpoint = blackListedOutpoints[i]; - if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) { - shouldHide = true; - break; - } - } + shouldHide = blackListedOutpoints.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout); + } + + if (claim && !shouldHide && filteredOutpoints) { + shouldHide = filteredOutpoints.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout); } function handleContextMenu(e) { diff --git a/src/ui/index.jsx b/src/ui/index.jsx index 23fa738c8..28ab11c74 100644 --- a/src/ui/index.jsx +++ b/src/ui/index.jsx @@ -14,7 +14,13 @@ import { Provider } from 'react-redux'; import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app'; import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux'; import { doInitLanguage, doUpdateIsNightAsync } from 'redux/actions/settings'; -import { doAuthenticate, Lbryio, rewards, doBlackListedOutpointsSubscribe } from 'lbryinc'; +import { + doAuthenticate, + Lbryio, + rewards, + doBlackListedOutpointsSubscribe, + doFilteredOutpointsSubscribe, +} from 'lbryinc'; import { store, history } from 'store'; import pjson from 'package.json'; import app from './app'; @@ -216,6 +222,7 @@ const init = () => { app.store.dispatch(doInitLanguage()); app.store.dispatch(doBlackListedOutpointsSubscribe()); + app.store.dispatch(doFilteredOutpointsSubscribe()); function onDaemonReady() { // @if TARGET='app' diff --git a/src/ui/reducers.js b/src/ui/reducers.js index 43e83882a..66f0ae7c0 100644 --- a/src/ui/reducers.js +++ b/src/ui/reducers.js @@ -9,7 +9,15 @@ import { tagsReducer, commentReducer, } from 'lbry-redux'; -import { userReducer, rewardsReducer, costInfoReducer, blacklistReducer, homepageReducer, statsReducer } from 'lbryinc'; +import { + userReducer, + rewardsReducer, + costInfoReducer, + blacklistReducer, + filteredReducer, + homepageReducer, + statsReducer, +} from 'lbryinc'; import appReducer from 'redux/reducers/app'; import availabilityReducer from 'redux/reducers/availability'; import contentReducer from 'redux/reducers/content'; @@ -23,6 +31,7 @@ export default history => app: appReducer, availability: availabilityReducer, blacklist: blacklistReducer, + filtered: filteredReducer, claims: claimsReducer, comments: commentReducer, content: contentReducer,