From 5b0846215f67786d5f83995ee9fc6923b9bc27f0 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 24 Apr 2018 14:17:11 -0400 Subject: [PATCH] add blacklisted content view --- package.json | 2 +- src/renderer/index.js | 20 +++++++-------- src/renderer/page/show/index.js | 8 +++++- src/renderer/page/show/view.jsx | 45 ++++++++++++++++++++++++++++++--- src/renderer/store.js | 2 ++ yarn.lock | 3 +-- 6 files changed, 63 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 6aa7fd706..92a61c412 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "find-process": "^1.1.0", "formik": "^0.10.4", "keytar": "^4.2.1", - "lbry-redux": "lbryio/lbry-redux", + "lbry-redux": "file:../lbry-redux", "localforage": "^1.7.1", "mixpanel-browser": "^2.17.1", "moment": "^2.22.0", diff --git a/src/renderer/index.js b/src/renderer/index.js index 60167d2df..c82db3287 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -7,12 +7,8 @@ import { ipcRenderer, remote, shell } from 'electron'; import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; -import { - doConditionalAuthNavigate, - doDaemonReady, - doAutoUpdate, -} from 'redux/actions/app'; -import { doNotify } from 'lbry-redux'; +import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate } from 'redux/actions/app'; +import { doNotify, doBlackListedOutpointsSubscribe } from 'lbry-redux'; import { doNavigate } from 'redux/actions/navigation'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; import { doUserEmailVerify } from 'redux/actions/user'; @@ -38,10 +34,12 @@ ipcRenderer.on('open-uri-requested', (event, uri, newSession) => { app.store.dispatch(doConditionalAuthNavigate(newSession)); app.store.dispatch(doUserEmailVerify(verification.token, verification.recaptcha)); } else { - app.store.dispatch(doNotify({ - message: 'Invalid Verification URI', - displayType: ['snackbar'] - })); + app.store.dispatch( + doNotify({ + message: 'Invalid Verification URI', + displayType: ['snackbar'], + }) + ); } } else { app.store.dispatch(doNavigate('/show', { uri })); @@ -119,8 +117,10 @@ const init = () => { app.store.dispatch(doAutoUpdate()); }); } + app.store.dispatch(doUpdateIsNightAsync()); app.store.dispatch(doDownloadLanguages()); + app.store.dispatch(doBlackListedOutpointsSubscribe()); function onDaemonReady() { window.sessionStorage.setItem('loaded', 'y'); // once we've made it here once per session, we don't need to show splash again diff --git a/src/renderer/page/show/index.js b/src/renderer/page/show/index.js index cdb0c981c..122c6774a 100644 --- a/src/renderer/page/show/index.js +++ b/src/renderer/page/show/index.js @@ -1,10 +1,16 @@ import { connect } from 'react-redux'; -import { doResolveUri, makeSelectClaimForUri, makeSelectIsUriResolving } from 'lbry-redux'; +import { + doResolveUri, + makeSelectClaimForUri, + makeSelectIsUriResolving, + selectBlackListedOutpoints, +} from 'lbry-redux'; import ShowPage from './view'; const select = (state, props) => ({ claim: makeSelectClaimForUri(props.uri)(state), isResolvingUri: makeSelectIsUriResolving(props.uri)(state), + blackListedOutpoints: selectBlackListedOutpoints(state), }); const perform = dispatch => ({ diff --git a/src/renderer/page/show/view.jsx b/src/renderer/page/show/view.jsx index acfae0bed..aa6e042ad 100644 --- a/src/renderer/page/show/view.jsx +++ b/src/renderer/page/show/view.jsx @@ -4,12 +4,21 @@ import BusyIndicator from 'component/common/busy-indicator'; import ChannelPage from 'page/channel'; import FilePage from 'page/file'; import Page from 'component/page'; +import Button from 'component/button'; type Props = { isResolvingUri: boolean, resolveUri: string => void, uri: string, - claim: { name: string }, + claim: { + name: string, + txid: string, + nout: number, + }, + blackListedOutpoints: Array<{ + txid: string, + nout: number, + }>, }; class ShowPage extends React.PureComponent { @@ -28,7 +37,7 @@ class ShowPage extends React.PureComponent { } render() { - const { claim, isResolvingUri, uri } = this.props; + const { claim, isResolvingUri, uri, blackListedOutpoints } = this.props; let innerContent = ''; @@ -50,7 +59,37 @@ class ShowPage extends React.PureComponent { } else if (claim && claim.name.length && claim.name[0] === '@') { innerContent = ; } else if (claim) { - innerContent = ; + let isClaimBlackListed = false; + + for (let i = 0; i < blackListedOutpoints.length; i += 1) { + const outpoint = blackListedOutpoints[i]; + if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) { + isClaimBlackListed = true; + break; + } + } + + if (isClaimBlackListed) { + innerContent = ( + +
+
{uri}
+
+

+ {__( + 'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.' + )} +

+
+
+
+
+
+ ); + } else { + innerContent = ; + } } return innerContent; diff --git a/src/renderer/store.js b/src/renderer/store.js index 36f8ac3f5..7ab581a7b 100644 --- a/src/renderer/store.js +++ b/src/renderer/store.js @@ -9,6 +9,7 @@ import { searchReducer, walletReducer, notificationsReducer, + blacklistReducer, } from 'lbry-redux'; import navigationReducer from 'redux/reducers/navigation'; import rewardsReducer from 'redux/reducers/rewards'; @@ -71,6 +72,7 @@ const reducers = combineReducers({ media: mediaReducer, publish: publishReducer, notifications: notificationsReducer, + blacklist: blacklistReducer, }); const bulkThunk = createBulkThunkMiddleware(); diff --git a/yarn.lock b/yarn.lock index c224ec987..b3c9a9549 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5422,9 +5422,8 @@ lazy-val@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/lazy-val/-/lazy-val-1.0.3.tgz#bb97b200ef00801d94c317e29dc6ed39e31c5edc" -lbry-redux@lbryio/lbry-redux: +"lbry-redux@file:../lbry-redux": version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/06cfc1c88cc4cc6dafd97647cd7529e0571256da" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0"