hide blacklisted and filtered outpoints from lists

This commit is contained in:
Akinwale Ariwodola 2019-07-31 12:18:09 +01:00
parent 4fc0056e9e
commit 60b4210c53
6 changed files with 24 additions and 11 deletions

4
package-lock.json generated
View file

@ -5019,8 +5019,8 @@
}
},
"lbry-redux": {
"version": "github:lbryio/lbry-redux#b2044499c5f43e519384433538c1225d56d3a1f2",
"from": "github:lbryio/lbry-redux#multi-claim-search",
"version": "github:lbryio/lbry-redux#cd23c12fb7fd541d28d7cbf3874b1058b036fd13",
"from": "github:lbryio/lbry-redux#cd23c12fb7fd541d28d7cbf3874b1058b036fd13",
"requires": {
"proxy-polyfill": "0.1.6",
"reselect": "^3.0.0",

View file

@ -8,12 +8,15 @@ import {
makeSelectTitleForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import FileListItem from './view';
const select = (state, props) => ({
blackListedOutpoints: selectBlackListedOutpoints(state),
claim: makeSelectClaimForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
filteredOutpoints: selectFilteredOutpoints(state),
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),

View file

@ -48,8 +48,10 @@ class FileListItem extends React.PureComponent {
render() {
const {
blackListedOutpoints,
claim,
fileInfo,
filteredOutpoints,
metadata,
featuredResult,
isResolvingUri,
@ -66,7 +68,7 @@ class FileListItem extends React.PureComponent {
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
const isResolving = !fileInfo && isResolvingUri;
let name, channel, height, channelClaimId, fullChannelUri, signingChannel;
let name, channel, height, channelClaimId, fullChannelUri, shouldHide, signingChannel;
if (claim) {
name = claim.name;
signingChannel = claim.signing_channel;
@ -74,9 +76,14 @@ class FileListItem extends React.PureComponent {
height = claim.height;
channelClaimId = signingChannel ? signingChannel.claim_id : null;
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
if (blackListedOutpoints || filteredOutpoints) {
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
}
}
if (featuredResult && !isResolvingUri && !claim && !title && !name) {
if (shouldHide || (featuredResult && !isResolvingUri && !claim && !title && !name)) {
return null;
}

View file

@ -18,6 +18,7 @@ import {
authReducer,
blacklistReducer,
costInfoReducer,
filteredReducer,
homepageReducer,
rewardsReducer,
subscriptionsReducer,
@ -109,6 +110,7 @@ const reducers = persistCombineReducers(persistOptions, {
drawer: drawerReducer,
file: fileReducer,
fileInfo: fileInfoReducer,
filtered: filteredReducer,
homepage: homepageReducer,
nav: navigatorReducer,
notifications: notificationsReducer,

View file

@ -3,6 +3,7 @@ import { doBalanceSubscribe, doUpdateBlockHeight, doToast } from 'lbry-redux';
import {
doAuthenticate,
doBlackListedOutpointsSubscribe,
doFilteredOutpointsSubscribe,
doCheckSubscriptionsInit,
doFetchMySubscriptions,
doFetchRewardedContent,
@ -25,6 +26,7 @@ const perform = dispatch => ({
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()),
filteredOutpointsSubscribe: () => dispatch(doFilteredOutpointsSubscribe()),
checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()),
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
fetchSubscriptions: callback => dispatch(doFetchMySubscriptions(callback)),

View file

@ -10,7 +10,7 @@ import Button from 'component/button';
import ProgressBar from 'component/progressBar';
import PropTypes from 'prop-types';
import Colors from 'styles/colors';
import Constants from 'constants';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import splashStyle from 'styles/splash';
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
@ -50,7 +50,7 @@ class SplashScreen extends React.PureComponent {
}
navigateToMain = () => {
const { navigation } = this.props;
const { navigation, notify, verifyUserEmail, verifyUserEmailFailure } = this.props;
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Main' })],
@ -114,9 +114,8 @@ class SplashScreen extends React.PureComponent {
balanceSubscribe,
blacklistedOutpointsSubscribe,
checkSubscriptionsInit,
filteredOutpointsSubscribe,
getSync,
navigation,
notify,
updateBlockHeight,
user,
} = this.props;
@ -125,6 +124,7 @@ class SplashScreen extends React.PureComponent {
// Leave the splash screen
balanceSubscribe();
blacklistedOutpointsSubscribe();
filteredOutpointsSubscribe();
checkSubscriptionsInit();
updateBlockHeight();
setInterval(() => {
@ -186,7 +186,6 @@ class SplashScreen extends React.PureComponent {
this.finishSplashScreen();
})
.catch(() => this.handleAccountUnlockFailed());
return;
} else {
this.setState({
message: testingNetwork,
@ -222,7 +221,7 @@ class SplashScreen extends React.PureComponent {
});
} else if (walletStatus && walletStatus.blocks_behind > 0) {
const behind = walletStatus.blocks_behind;
const behindText = behind + ' block' + (behind == 1 ? '' : 's') + ' behind';
const behindText = behind + ' block' + (behind === 1 ? '' : 's') + ' behind';
this.setState({
message: 'Blockchain Sync',
details: behindText,
@ -254,7 +253,7 @@ class SplashScreen extends React.PureComponent {
// Start measuring the first launch time from the splash screen
// (time to first user interaction - after first run completed)
AsyncStorage.getItem('hasLaunched').then(value => {
if ('true' !== value) {
if (value !== 'true') {
AsyncStorage.setItem('hasLaunched', 'true');
// only set firstLaunchTime since we've determined that this is the first app launch ever
AsyncStorage.setItem('firstLaunchTime', String(moment().unix()));