Filter preview (#2621)

* discovery previews use filter api

* updates lbryinc

* refactor
This commit is contained in:
jessopb 2019-07-16 23:32:29 -04:00 committed by Thomas Zarebczan
parent 04e53ecda1
commit 112ffe6696
5 changed files with 32 additions and 11 deletions

View file

@ -125,7 +125,7 @@
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#bb82aed61a5569e565daa784eb25fc1d639c0c22", "lbry-redux": "lbryio/lbry-redux#bb82aed61a5569e565daa784eb25fc1d639c0c22",
"lbryinc": "lbryio/lbryinc#43d382d9b74d396a581a74d87e4c53105e04f845", "lbryinc": "lbryio/lbryinc#69f9562b016030b481375443f56147ff5e273c0e",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",
"lodash-es": "^4.17.14", "lodash-es": "^4.17.14",

View file

@ -9,7 +9,7 @@ import {
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectClaimIsNsfw, makeSelectClaimIsNsfw,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlackListedOutpoints } from 'lbryinc'; import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings'; import { selectShowNsfw } from 'redux/selectors/settings';
import ClaimPreview from './view'; import ClaimPreview from './view';
@ -23,6 +23,7 @@ const select = (state, props) => ({
title: makeSelectTitleForUri(props.uri)(state), title: makeSelectTitleForUri(props.uri)(state),
nsfw: makeSelectClaimIsNsfw(props.uri)(state), nsfw: makeSelectClaimIsNsfw(props.uri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state), blackListedOutpoints: selectBlackListedOutpoints(state),
filteredOutpoints: selectFilteredOutpoints(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -33,6 +33,10 @@ type Props = {
txid: string, txid: string,
nout: number, nout: number,
}>, }>,
filteredOutpoints: Array<{
txid: string,
nout: number,
}>,
}; };
function ClaimPreview(props: Props) { function ClaimPreview(props: Props) {
@ -51,6 +55,7 @@ function ClaimPreview(props: Props) {
placeholder, placeholder,
type, type,
blackListedOutpoints, blackListedOutpoints,
filteredOutpoints,
} = props; } = props;
const haventFetched = claim === undefined; const haventFetched = claim === undefined;
const abandoned = !isResolvingUri && !claim && !placeholder; const abandoned = !isResolvingUri && !claim && !placeholder;
@ -60,14 +65,13 @@ function ClaimPreview(props: Props) {
let shouldHide = abandoned || (!claimIsMine && obscureNsfw && nsfw); let shouldHide = abandoned || (!claimIsMine && obscureNsfw && nsfw);
// This will be replaced once blocking is done at the wallet server level // This will be replaced once blocking is done at the wallet server level
if (claim && !shouldHide && blackListedOutpoints) { if (claim && !shouldHide && blackListedOutpoints) {
for (let i = 0; i < blackListedOutpoints.length; i += 1) { shouldHide = blackListedOutpoints.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
const outpoint = blackListedOutpoints[i];
if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) {
shouldHide = true;
break;
}
} }
if (claim && !shouldHide && filteredOutpoints) {
shouldHide = filteredOutpoints.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
} }
function handleContextMenu(e) { function handleContextMenu(e) {

View file

@ -14,7 +14,13 @@ import { Provider } from 'react-redux';
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app'; import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app';
import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux'; import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux';
import { doInitLanguage, doUpdateIsNightAsync } from 'redux/actions/settings'; 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 { store, history } from 'store';
import pjson from 'package.json'; import pjson from 'package.json';
import app from './app'; import app from './app';
@ -216,6 +222,7 @@ const init = () => {
app.store.dispatch(doInitLanguage()); app.store.dispatch(doInitLanguage());
app.store.dispatch(doBlackListedOutpointsSubscribe()); app.store.dispatch(doBlackListedOutpointsSubscribe());
app.store.dispatch(doFilteredOutpointsSubscribe());
function onDaemonReady() { function onDaemonReady() {
// @if TARGET='app' // @if TARGET='app'

View file

@ -9,7 +9,15 @@ import {
tagsReducer, tagsReducer,
commentReducer, commentReducer,
} from 'lbry-redux'; } 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 appReducer from 'redux/reducers/app';
import availabilityReducer from 'redux/reducers/availability'; import availabilityReducer from 'redux/reducers/availability';
import contentReducer from 'redux/reducers/content'; import contentReducer from 'redux/reducers/content';
@ -23,6 +31,7 @@ export default history =>
app: appReducer, app: appReducer,
availability: availabilityReducer, availability: availabilityReducer,
blacklist: blacklistReducer, blacklist: blacklistReducer,
filtered: filteredReducer,
claims: claimsReducer, claims: claimsReducer,
comments: commentReducer, comments: commentReducer,
content: contentReducer, content: contentReducer,