ClaimPreviewTile state-map optimizations
## Issue Lots of time is spent mapping the state to props for this component (since there are lots of tiles). ## Changes Using this component as a starting point, go through the selectors and make the usual cleanup/fixes: - Move away from the `makeSelect*` model, which creates a new selector on every call instead of actually re-using the cached version. - Do proper caching for multi-param selectors using `re-reselect`. - Don't cache simple functions or direct access to states.
This commit is contained in:
commit
39baf1a3c9
54 changed files with 309 additions and 377 deletions
|
@ -53,7 +53,7 @@ export { selectFilteredOutpoints, selectFilteredOutpointMap } from './redux/sele
|
||||||
// selectTrendingUris,
|
// selectTrendingUris,
|
||||||
// selectFetchingTrendingUris,
|
// selectFetchingTrendingUris,
|
||||||
// } from './redux/selectors/homepage';
|
// } from './redux/selectors/homepage';
|
||||||
export { selectViewCount, makeSelectViewCountForUri, makeSelectSubCountForUri } from './redux/selectors/stats';
|
export { selectViewCount, selectViewCountForUri, selectSubCountForUri } from './redux/selectors/stats';
|
||||||
export { selectBanStateForUri } from './redux/selectors/ban';
|
export { selectBanStateForUri } from './redux/selectors/ban';
|
||||||
export {
|
export {
|
||||||
selectHasSyncedWallet,
|
selectHasSyncedWallet,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
import { selectClaimsByUri } from 'redux/selectors/claims';
|
import { selectClaimForUri } from 'redux/selectors/claims';
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export function doFetchCostInfoForUri(uri) {
|
export function doFetchCostInfoForUri(uri) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const claim = selectClaimsByUri(state)[uri];
|
const claim = selectClaimForUri(state, uri);
|
||||||
|
|
||||||
if (!claim) return;
|
if (!claim) return;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import { createSelector } from 'reselect';
|
// @flow
|
||||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { selectClaimIdForUri } from 'redux/selectors/claims';
|
||||||
|
|
||||||
const selectState = state => state.stats || {};
|
type State = { claims: any, stats: any };
|
||||||
export const selectViewCount = createSelector(selectState, state => state.viewCountById);
|
|
||||||
export const selectSubCount = createSelector(selectState, state => state.subCountById);
|
|
||||||
|
|
||||||
export const makeSelectViewCountForUri = uri =>
|
const selectState = (state: State) => state.stats || {};
|
||||||
createSelector(
|
export const selectViewCount = (state: State) => selectState(state).viewCountById;
|
||||||
makeSelectClaimForUri(uri),
|
export const selectSubCount = (state: State) => selectState(state).subCountById;
|
||||||
selectViewCount,
|
|
||||||
(claim, viewCountById) => (claim ? viewCountById[claim.claim_id] || 0 : 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
export const makeSelectSubCountForUri = uri =>
|
export const selectViewCountForUri = (state: State, uri: string) => {
|
||||||
createSelector(
|
const claimId = selectClaimIdForUri(state, uri);
|
||||||
makeSelectClaimForUri(uri),
|
const viewCountById = selectViewCount(state);
|
||||||
selectSubCount,
|
return claimId ? viewCountById[claimId] || 0 : 0;
|
||||||
(claim, subCountById) => (claim ? subCountById[claim.claim_id] || 0 : 0)
|
};
|
||||||
);
|
|
||||||
|
export const selectSubCountForUri = (state: State, uri: string) => {
|
||||||
|
const claimId = selectClaimIdForUri(state, uri);
|
||||||
|
const subCountById = selectSubCount(state);
|
||||||
|
return claimId ? subCountById[claimId] || 0 : 0;
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
selectThumbnailForUri,
|
selectThumbnailForUri,
|
||||||
makeSelectCoverForUri,
|
makeSelectCoverForUri,
|
||||||
makeSelectMetadataItemForUri,
|
makeSelectMetadataItemForUri,
|
||||||
|
@ -21,7 +21,7 @@ import ChannelForm from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
thumbnailUrl: selectThumbnailForUri(state, props.uri),
|
thumbnailUrl: selectThumbnailForUri(state, props.uri),
|
||||||
coverUrl: makeSelectCoverForUri(props.uri)(state),
|
coverUrl: makeSelectCoverForUri(props.uri)(state),
|
||||||
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { selectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import ChannelMentionSuggestion from './view';
|
import ChannelMentionSuggestion from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: selectClaimForUri(state, props.uri),
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: selectIsUriResolving(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(ChannelMentionSuggestion);
|
export default connect(select)(ChannelMentionSuggestion);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
|
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
|
||||||
import ChannelMentionTopSuggestion from './view';
|
import ChannelMentionTopSuggestion from './view';
|
||||||
|
@ -8,7 +8,7 @@ const select = (state, props) => {
|
||||||
const uriFromQuery = `lbry://${props.query}`;
|
const uriFromQuery = `lbry://${props.query}`;
|
||||||
return {
|
return {
|
||||||
uriFromQuery,
|
uriFromQuery,
|
||||||
isResolvingUri: makeSelectIsUriResolving(uriFromQuery)(state),
|
isResolvingUri: selectIsUriResolving(state, uriFromQuery),
|
||||||
winningUri: makeSelectWinningUriForQuery(props.query)(state),
|
winningUri: makeSelectWinningUriForQuery(props.query)(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectThumbnailForUri, selectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { selectThumbnailForUri, selectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import ChannelThumbnail from './view';
|
import ChannelThumbnail from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
thumbnail: selectThumbnailForUri(state, props.uri),
|
thumbnail: selectThumbnailForUri(state, props.uri),
|
||||||
claim: selectClaimForUri(state, props.uri),
|
claim: selectClaimForUri(state, props.uri),
|
||||||
isResolving: makeSelectIsUriResolving(props.uri)(state),
|
isResolving: selectIsUriResolving(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, {
|
export default connect(select, {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import ChannelTitle from './view';
|
import ChannelTitle from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { doSetPlayingUri } from 'redux/actions/content';
|
import { doSetPlayingUri } from 'redux/actions/content';
|
||||||
import { punctuationMarks } from 'util/remark-lbry';
|
import { punctuationMarks } from 'util/remark-lbry';
|
||||||
|
@ -25,7 +25,7 @@ const select = (state, props) => {
|
||||||
uri,
|
uri,
|
||||||
claim,
|
claim,
|
||||||
fullUri: props.uri,
|
fullUri: props.uri,
|
||||||
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
isResolvingUri: selectIsUriResolving(state, uri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
playingUri: selectPlayingUri(state),
|
playingUri: selectPlayingUri(state),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
selectClaimForUri,
|
selectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
makeSelectClaimIsPending,
|
makeSelectClaimIsPending,
|
||||||
makeSelectClaimIsNsfw,
|
|
||||||
makeSelectReflectingClaimForUri,
|
makeSelectReflectingClaimForUri,
|
||||||
makeSelectClaimWasPurchased,
|
makeSelectClaimWasPurchased,
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
isStreamPlaceholderClaim,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
selectDateForUri,
|
selectDateForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
||||||
|
@ -22,10 +21,11 @@ import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { doCollectionEdit } from 'redux/actions/collections';
|
import { doCollectionEdit } from 'redux/actions/collections';
|
||||||
import { doFileGet } from 'redux/actions/file';
|
import { doFileGet } from 'redux/actions/file';
|
||||||
import { selectBanStateForUri } from 'lbryinc';
|
import { selectBanStateForUri } from 'lbryinc';
|
||||||
import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream';
|
import { selectIsActiveLivestreamForUri } from 'redux/selectors/livestream';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
|
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
|
||||||
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
||||||
|
import { isClaimNsfw } from 'util/claim';
|
||||||
import ClaimPreview from './view';
|
import ClaimPreview from './view';
|
||||||
import formatMediaDuration from 'util/formatMediaDuration';
|
import formatMediaDuration from 'util/formatMediaDuration';
|
||||||
|
|
||||||
|
@ -33,26 +33,27 @@ const select = (state, props) => {
|
||||||
const claim = props.uri && selectClaimForUri(state, props.uri);
|
const claim = props.uri && selectClaimForUri(state, props.uri);
|
||||||
const media = claim && claim.value && (claim.value.video || claim.value.audio);
|
const media = claim && claim.value && (claim.value.video || claim.value.audio);
|
||||||
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
|
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
|
||||||
|
const isLivestream = isStreamPlaceholderClaim(claim);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
claim,
|
claim,
|
||||||
mediaDuration,
|
mediaDuration,
|
||||||
date: props.uri && selectDateForUri(state, props.uri),
|
date: props.uri && selectDateForUri(state, props.uri),
|
||||||
title: props.uri && makeSelectTitleForUri(props.uri)(state),
|
title: props.uri && selectTitleForUri(state, props.uri),
|
||||||
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
|
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
|
||||||
reflectingProgress: props.uri && makeSelectReflectingClaimForUri(props.uri)(state),
|
reflectingProgress: props.uri && makeSelectReflectingClaimForUri(props.uri)(state),
|
||||||
obscureNsfw: selectShowMatureContent(state) === false,
|
obscureNsfw: selectShowMatureContent(state) === false,
|
||||||
claimIsMine: props.uri && selectClaimIsMine(state, claim),
|
claimIsMine: props.uri && selectClaimIsMine(state, claim),
|
||||||
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
|
||||||
isResolvingRepost: props.uri && makeSelectIsUriResolving(props.repostUrl)(state),
|
isResolvingRepost: props.uri && selectIsUriResolving(state, props.repostUrl),
|
||||||
nsfw: props.uri && makeSelectClaimIsNsfw(props.uri)(state),
|
nsfw: claim ? isClaimNsfw(claim) : false,
|
||||||
banState: selectBanStateForUri(state, props.uri),
|
banState: selectBanStateForUri(state, props.uri),
|
||||||
hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state),
|
hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state),
|
||||||
isSubscribed: props.uri && selectIsSubscribedForUri(state, props.uri),
|
isSubscribed: props.uri && selectIsSubscribedForUri(state, props.uri),
|
||||||
streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state),
|
streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state),
|
||||||
wasPurchased: props.uri && makeSelectClaimWasPurchased(props.uri)(state),
|
wasPurchased: props.uri && makeSelectClaimWasPurchased(props.uri)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream,
|
||||||
isLivestreamActive: makeSelectIsActiveLivestream(props.uri)(state),
|
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
|
||||||
isCollectionMine: makeSelectCollectionIsMine(props.collectionId)(state),
|
isCollectionMine: makeSelectCollectionIsMine(props.collectionId)(state),
|
||||||
collectionUris: makeSelectUrlsForCollectionId(props.collectionId)(state),
|
collectionUris: makeSelectUrlsForCollectionId(props.collectionId)(state),
|
||||||
collectionIndex: makeSelectIndexForUrlInCollection(props.uri, props.collectionId)(state),
|
collectionIndex: makeSelectIndexForUrlInCollection(props.uri, props.collectionId)(state),
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import { selectClaimForUri, makeSelectClaimIsPending, isStreamPlaceholderClaim } from 'redux/selectors/claims';
|
||||||
selectClaimForUri,
|
|
||||||
makeSelectClaimIsPending,
|
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
|
||||||
} from 'redux/selectors/claims';
|
|
||||||
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
|
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
import ClaimPreviewSubtitle from './view';
|
import ClaimPreviewSubtitle from './view';
|
||||||
import { doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
|
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
const claim = selectClaimForUri(state, props.uri);
|
const claim = selectClaimForUri(state, props.uri);
|
||||||
|
@ -17,8 +13,8 @@ const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
claim,
|
claim,
|
||||||
pending: makeSelectClaimIsPending(props.uri)(state),
|
pending: makeSelectClaimIsPending(props.uri)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream: isStreamPlaceholderClaim(claim),
|
||||||
subCount: isChannel ? makeSelectSubCountForUri(props.uri)(state) : 0,
|
subCount: isChannel ? selectSubCountForUri(state, props.uri) : 0,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
getThumbnailFromClaim,
|
getThumbnailFromClaim,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
makeSelectChannelForClaimUri,
|
isStreamPlaceholderClaim,
|
||||||
makeSelectClaimIsNsfw,
|
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
|
||||||
selectDateForUri,
|
selectDateForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { doFileGet } from 'redux/actions/file';
|
import { doFileGet } from 'redux/actions/file';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { makeSelectViewCountForUri, selectBanStateForUri } from 'lbryinc';
|
import { selectViewCountForUri, selectBanStateForUri } from 'lbryinc';
|
||||||
import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream';
|
import { selectIsActiveLivestreamForUri } from 'redux/selectors/livestream';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
|
import { isClaimNsfw } from 'util/claim';
|
||||||
import ClaimPreviewTile from './view';
|
import ClaimPreviewTile from './view';
|
||||||
import formatMediaDuration from 'util/formatMediaDuration';
|
import formatMediaDuration from 'util/formatMediaDuration';
|
||||||
|
|
||||||
|
@ -21,21 +20,21 @@ const select = (state, props) => {
|
||||||
const claim = props.uri && makeSelectClaimForUri(props.uri)(state);
|
const claim = props.uri && makeSelectClaimForUri(props.uri)(state);
|
||||||
const media = claim && claim.value && (claim.value.video || claim.value.audio);
|
const media = claim && claim.value && (claim.value.video || claim.value.audio);
|
||||||
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
|
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
|
||||||
|
const isLivestream = isStreamPlaceholderClaim(claim);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
claim,
|
claim,
|
||||||
mediaDuration,
|
mediaDuration,
|
||||||
date: props.uri && selectDateForUri(state, props.uri),
|
date: props.uri && selectDateForUri(state, props.uri),
|
||||||
channel: props.uri && makeSelectChannelForClaimUri(props.uri)(state),
|
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
|
||||||
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
|
|
||||||
thumbnail: getThumbnailFromClaim(claim),
|
thumbnail: getThumbnailFromClaim(claim),
|
||||||
title: props.uri && makeSelectTitleForUri(props.uri)(state),
|
title: props.uri && selectTitleForUri(state, props.uri),
|
||||||
banState: selectBanStateForUri(state, props.uri),
|
banState: selectBanStateForUri(state, props.uri),
|
||||||
showMature: selectShowMatureContent(state),
|
showMature: selectShowMatureContent(state),
|
||||||
isMature: makeSelectClaimIsNsfw(props.uri)(state),
|
isMature: claim ? isClaimNsfw(claim) : false,
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream,
|
||||||
isLivestreamActive: makeSelectIsActiveLivestream(props.uri)(state),
|
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
|
||||||
viewCount: makeSelectViewCountForUri(props.uri)(state),
|
viewCount: selectViewCountForUri(state, props.uri),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import ClaimPreviewTitle from './view';
|
import ClaimPreviewTitle from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(ClaimPreviewTitle);
|
export default connect(select)(ClaimPreviewTitle);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
||||||
import FileType from './view';
|
import FileType from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream: selectIsStreamPlaceholderForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(FileType);
|
export default connect(select)(FileType);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
selectThumbnailForUri,
|
selectThumbnailForUri,
|
||||||
makeSelectMetadataItemForUri,
|
makeSelectMetadataItemForUri,
|
||||||
makeSelectAmountForUri,
|
makeSelectAmountForUri,
|
||||||
|
@ -25,7 +25,7 @@ import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
thumbnailUrl: selectThumbnailForUri(state, props.uri),
|
thumbnailUrl: selectThumbnailForUri(state, props.uri),
|
||||||
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
||||||
tags: makeSelectMetadataItemForUri(props.uri, 'tags')(state),
|
tags: makeSelectMetadataItemForUri(props.uri, 'tags')(state),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectIsUriResolving, selectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
|
import { selectIsUriResolving, selectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
|
||||||
import {
|
import {
|
||||||
makeSelectUrlsForCollectionId,
|
makeSelectUrlsForCollectionId,
|
||||||
makeSelectNameForCollectionId,
|
makeSelectNameForCollectionId,
|
||||||
|
@ -22,7 +22,7 @@ const select = (state, props) => {
|
||||||
collectionItemUrls: makeSelectUrlsForCollectionId(collectionId)(state), // ForId || ForUri
|
collectionItemUrls: makeSelectUrlsForCollectionId(collectionId)(state), // ForId || ForUri
|
||||||
pendingCollection: makeSelectPendingCollectionForId(collectionId)(state),
|
pendingCollection: makeSelectPendingCollectionForId(collectionId)(state),
|
||||||
claim,
|
claim,
|
||||||
isResolvingUri: collectionUri && makeSelectIsUriResolving(collectionUri)(state),
|
isResolvingUri: collectionUri && selectIsUriResolving(state, collectionUri),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
getThumbnailFromClaim,
|
getThumbnailFromClaim,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
makeSelectChannelForClaimUri,
|
makeSelectChannelForClaimUri,
|
||||||
makeSelectClaimIsNsfw,
|
selectClaimIsNsfwForUri,
|
||||||
selectClaimIdForUri,
|
selectClaimIdForUri,
|
||||||
makeSelectClaimForClaimId,
|
makeSelectClaimForClaimId,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
@ -39,14 +39,14 @@ const select = (state, props) => {
|
||||||
claim,
|
claim,
|
||||||
isResolvingCollectionClaims: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
isResolvingCollectionClaims: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
||||||
channelClaim: collectionUri && makeSelectChannelForClaimUri(collectionUri)(state),
|
channelClaim: collectionUri && makeSelectChannelForClaimUri(collectionUri)(state),
|
||||||
isResolvingUri: collectionUri && makeSelectIsUriResolving(collectionUri)(state),
|
isResolvingUri: collectionUri && selectIsUriResolving(state, collectionUri),
|
||||||
thumbnail: getThumbnailFromClaim(claim),
|
thumbnail: getThumbnailFromClaim(claim),
|
||||||
title: collectionUri && makeSelectTitleForUri(collectionUri)(state),
|
title: collectionUri && selectTitleForUri(state, collectionUri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
filteredOutpoints: selectFilteredOutpoints(state),
|
filteredOutpoints: selectFilteredOutpoints(state),
|
||||||
blockedChannelUris: selectMutedChannels(state),
|
blockedChannelUris: selectMutedChannels(state),
|
||||||
showMature: selectShowMatureContent(state),
|
showMature: selectShowMatureContent(state),
|
||||||
isMature: makeSelectClaimIsNsfw(collectionUri)(state),
|
isMature: selectClaimIsNsfwForUri(state, collectionUri),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
selectClaimForUri,
|
selectClaimForUri,
|
||||||
selectHasChannels,
|
selectHasChannels,
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
selectIsStreamPlaceholderForUri,
|
||||||
makeSelectTagInClaimOrChannelForUri,
|
makeSelectTagInClaimOrChannelForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { makeSelectStreamingUrlForUri, makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
import { makeSelectStreamingUrlForUri, makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
||||||
|
@ -27,7 +27,7 @@ const select = (state, props) => {
|
||||||
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
||||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||||
hasChannels: selectHasChannels(state),
|
hasChannels: selectHasChannels(state),
|
||||||
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, props.uri),
|
||||||
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectTitleForUri, makeSelectClaimIsNsfw, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
import { selectTitleForUri, selectClaimIsNsfwForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
||||||
import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
||||||
import {
|
import {
|
||||||
makeSelectNextUrlForCollectionAndUrl,
|
makeSelectNextUrlForCollectionAndUrl,
|
||||||
|
@ -30,9 +30,9 @@ const select = (state, props) => {
|
||||||
uri,
|
uri,
|
||||||
primaryUri,
|
primaryUri,
|
||||||
playingUri,
|
playingUri,
|
||||||
title: makeSelectTitleForUri(uri)(state),
|
title: selectTitleForUri(state, uri),
|
||||||
fileInfo: makeSelectFileInfoForUri(uri)(state),
|
fileInfo: makeSelectFileInfoForUri(uri)(state),
|
||||||
mature: makeSelectClaimIsNsfw(uri)(state),
|
mature: selectClaimIsNsfwForUri(state, uri),
|
||||||
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
||||||
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
|
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import {
|
import {
|
||||||
makeSelectIsPlaying,
|
makeSelectIsPlaying,
|
||||||
makeSelectShouldObscurePreview,
|
selectShouldObscurePreviewForUri,
|
||||||
makeSelectInsufficientCreditsForUri,
|
makeSelectInsufficientCreditsForUri,
|
||||||
makeSelectFileRenderModeForUri,
|
makeSelectFileRenderModeForUri,
|
||||||
} from 'redux/selectors/content';
|
} from 'redux/selectors/content';
|
||||||
|
@ -25,7 +25,7 @@ const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
claimThumbnail: selectThumbnailForUri(state, props.uri),
|
claimThumbnail: selectThumbnailForUri(state, props.uri),
|
||||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||||
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
|
obscurePreview: selectShouldObscurePreviewForUri(state, props.uri),
|
||||||
isPlaying: makeSelectIsPlaying(props.uri)(state),
|
isPlaying: makeSelectIsPlaying(props.uri)(state),
|
||||||
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
||||||
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state),
|
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state),
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import FileTitleSection from './view';
|
import FileTitleSection from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(FileTitleSection);
|
export default connect(select)(FileTitleSection);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
|
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
|
||||||
import { makeSelectTitleForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { selectTitleForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
|
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
|
||||||
import { makeSelectViewersForId } from 'redux/selectors/livestream';
|
import { makeSelectViewersForId } from 'redux/selectors/livestream';
|
||||||
import FileTitleSection from './view';
|
import FileTitleSection from './view';
|
||||||
|
@ -10,12 +10,12 @@ const select = (state, props) => {
|
||||||
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state);
|
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state);
|
||||||
const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined;
|
const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined;
|
||||||
const channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined;
|
const channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined;
|
||||||
const subCount = channelUri && makeSelectSubCountForUri(channelUri)(state);
|
const subCount = channelUri && selectSubCountForUri(state, channelUri);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
viewers,
|
viewers,
|
||||||
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
channelClaimId,
|
channelClaimId,
|
||||||
subCount,
|
subCount,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectMediaTypeForUri } from 'redux/selectors/file_info';
|
import { makeSelectMediaTypeForUri } from 'redux/selectors/file_info';
|
||||||
import { makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
||||||
import FileType from './view';
|
import FileType from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
mediaType: makeSelectMediaTypeForUri(props.uri)(state),
|
mediaType: makeSelectMediaTypeForUri(props.uri)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream: selectIsStreamPlaceholderForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(FileType);
|
export default connect(select)(FileType);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { doFetchViewCount, makeSelectViewCountForUri } from 'lbryinc';
|
import { doFetchViewCount, selectViewCountForUri } from 'lbryinc';
|
||||||
import { doAnalyticsView } from 'redux/actions/app';
|
import { doAnalyticsView } from 'redux/actions/app';
|
||||||
import FileViewCount from './view';
|
import FileViewCount from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
viewCount: makeSelectViewCountForUri(props.uri)(state),
|
viewCount: selectViewCountForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { selectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { makeSelectViewCountForUri } from 'lbryinc';
|
import { selectViewCountForUri } from 'lbryinc';
|
||||||
import { selectLanguage } from 'redux/selectors/settings';
|
import { selectLanguage } from 'redux/selectors/settings';
|
||||||
import FileViewCountInline from './view';
|
import FileViewCountInline from './view';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: selectClaimForUri(state, props.uri),
|
||||||
viewCount: makeSelectViewCountForUri(props.uri)(state),
|
viewCount: selectViewCountForUri(state, props.uri),
|
||||||
lang: selectLanguage(state),
|
lang: selectLanguage(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import fileViewerEmbeddedTitle from './view';
|
import fileViewerEmbeddedTitle from './view';
|
||||||
import { makeSelectTagInClaimOrChannelForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { makeSelectTagInClaimOrChannelForUri, selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import { PREFERENCE_EMBED } from 'constants/tags';
|
import { PREFERENCE_EMBED } from 'constants/tags';
|
||||||
|
|
||||||
export default connect((state, props) => {
|
export default connect((state, props) => {
|
||||||
return {
|
return {
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
preferEmbed: makeSelectTagInClaimOrChannelForUri(props.uri, PREFERENCE_EMBED)(state),
|
preferEmbed: makeSelectTagInClaimOrChannelForUri(props.uri, PREFERENCE_EMBED)(state),
|
||||||
};
|
};
|
||||||
})(fileViewerEmbeddedTitle);
|
})(fileViewerEmbeddedTitle);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
getThumbnailFromClaim,
|
getThumbnailFromClaim,
|
||||||
selectClaimForUri,
|
selectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
makeSelectMetadataItemForUri,
|
makeSelectMetadataItemForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
|
@ -17,11 +17,11 @@ const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
uri: props.uri,
|
uri: props.uri,
|
||||||
claim,
|
claim,
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
thumbnail: getThumbnailFromClaim(claim),
|
thumbnail: getThumbnailFromClaim(claim),
|
||||||
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
||||||
channelIsMine: selectClaimIsMine(state, claim),
|
channelIsMine: selectClaimIsMine(state, claim),
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: selectIsUriResolving(state, props.uri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import { selectBalance } from 'redux/selectors/wallet';
|
import { selectBalance } from 'redux/selectors/wallet';
|
||||||
import { selectIsStillEditing, makeSelectPublishFormValue } from 'redux/selectors/publish';
|
import { selectIsStillEditing, makeSelectPublishFormValue } from 'redux/selectors/publish';
|
||||||
import { doUpdatePublishForm, doClearPublish } from 'redux/actions/publish';
|
import { doUpdatePublishForm, doClearPublish } from 'redux/actions/publish';
|
||||||
import { makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
import { selectFfmpegStatus } from 'redux/selectors/settings';
|
import { selectFfmpegStatus } from 'redux/selectors/settings';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
@ -20,7 +20,7 @@ const select = (state, props) => ({
|
||||||
size: makeSelectPublishFormValue('fileSize')(state),
|
size: makeSelectPublishFormValue('fileSize')(state),
|
||||||
duration: makeSelectPublishFormValue('fileDur')(state),
|
duration: makeSelectPublishFormValue('fileDur')(state),
|
||||||
isVid: makeSelectPublishFormValue('fileVid')(state),
|
isVid: makeSelectPublishFormValue('fileVid')(state),
|
||||||
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
} from 'redux/selectors/publish';
|
} from 'redux/selectors/publish';
|
||||||
import { makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
||||||
import * as RENDER_MODES from 'constants/file_render_modes';
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
||||||
|
@ -45,7 +45,7 @@ const select = (state) => {
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
// The winning claim for a short lbry uri
|
// The winning claim for a short lbry uri
|
||||||
amountNeededForTakeover: selectTakeOverAmount(state),
|
amountNeededForTakeover: selectTakeOverAmount(state),
|
||||||
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(permanentUrl)(state),
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, permanentUrl),
|
||||||
isPostClaim,
|
isPostClaim,
|
||||||
permanentUrl,
|
permanentUrl,
|
||||||
// My previously published claims under this short lbry uri
|
// My previously published claims under this short lbry uri
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { doFetchRecommendedContent } from 'redux/actions/search';
|
import { doFetchRecommendedContent } from 'redux/actions/search';
|
||||||
import { makeSelectRecommendedContentForUri, selectIsSearching } from 'redux/selectors/search';
|
import { selectRecommendedContentForUri, selectIsSearching } from 'redux/selectors/search';
|
||||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
import RecommendedContent from './view';
|
import RecommendedContent from './view';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
const claim = makeSelectClaimForUri(props.uri)(state);
|
const claim = makeSelectClaimForUri(props.uri)(state);
|
||||||
const { claim_id: claimId } = claim;
|
const { claim_id: claimId } = claim;
|
||||||
const recommendedContentUris = makeSelectRecommendedContentForUri(props.uri)(state);
|
const recommendedContentUris = selectRecommendedContentForUri(state, props.uri);
|
||||||
const nextRecommendedUri = recommendedContentUris && recommendedContentUris[0];
|
const nextRecommendedUri = recommendedContentUris && recommendedContentUris[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { connect } from 'react-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
selectRepostError,
|
selectRepostError,
|
||||||
selectRepostLoading,
|
selectRepostLoading,
|
||||||
selectMyClaimsWithoutChannels,
|
selectMyClaimsWithoutChannels,
|
||||||
makeSelectEffectiveAmountForUri,
|
makeSelectEffectiveAmountForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
selectFetchingMyChannels,
|
selectFetchingMyChannels,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ const select = (state, props) => ({
|
||||||
enteredContentClaim: makeSelectClaimForUri(props.contentUri)(state),
|
enteredContentClaim: makeSelectClaimForUri(props.contentUri)(state),
|
||||||
enteredRepostClaim: makeSelectClaimForUri(props.repostUri, false)(state),
|
enteredRepostClaim: makeSelectClaimForUri(props.repostUri, false)(state),
|
||||||
enteredRepostAmount: makeSelectEffectiveAmountForUri(props.repostUri)(state),
|
enteredRepostAmount: makeSelectEffectiveAmountForUri(props.repostUri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
error: selectRepostError(state),
|
error: selectRepostError(state),
|
||||||
reposting: selectRepostLoading(state),
|
reposting: selectRepostLoading(state),
|
||||||
myClaims: selectMyClaimsWithoutChannels(state),
|
myClaims: selectMyClaimsWithoutChannels(state),
|
||||||
isResolvingPassedRepost: props.name && makeSelectIsUriResolving(`lbry://${props.name}`)(state),
|
isResolvingPassedRepost: props.name && selectIsUriResolving(state, `lbry://${props.name}`),
|
||||||
isResolvingEnteredRepost: props.repostUri && makeSelectIsUriResolving(`lbry://${props.repostUri}`)(state),
|
isResolvingEnteredRepost: props.repostUri && selectIsUriResolving(state, `lbry://${props.repostUri}`),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
fetchingMyChannels: selectFetchingMyChannels(state),
|
fetchingMyChannels: selectFetchingMyChannels(state),
|
||||||
incognito: selectIncognito(state),
|
incognito: selectIncognito(state),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { selectHasNavigated, selectScrollStartingPosition, selectWelcomeVersion
|
||||||
import { selectHomepageData } from 'redux/selectors/settings';
|
import { selectHomepageData } from 'redux/selectors/settings';
|
||||||
import Router from './view';
|
import Router from './view';
|
||||||
import { normalizeURI } from 'util/lbryURI';
|
import { normalizeURI } from 'util/lbryURI';
|
||||||
import { makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import { doSetHasNavigated } from 'redux/actions/app';
|
import { doSetHasNavigated } from 'redux/actions/app';
|
||||||
import { doUserSetReferrer } from 'redux/actions/user';
|
import { doUserSetReferrer } from 'redux/actions/user';
|
||||||
import { selectHasUnclaimedRefereeReward } from 'redux/selectors/rewards';
|
import { selectHasUnclaimedRefereeReward } from 'redux/selectors/rewards';
|
||||||
|
@ -28,7 +28,7 @@ const select = (state) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uri,
|
uri,
|
||||||
title: makeSelectTitleForUri(uri)(state),
|
title: selectTitleForUri(state, uri),
|
||||||
currentScroll: selectScrollStartingPosition(state),
|
currentScroll: selectScrollStartingPosition(state),
|
||||||
isAuthenticated: selectUserVerifiedEmail(state),
|
isAuthenticated: selectUserVerifiedEmail(state),
|
||||||
welcomeVersion: selectWelcomeVersion(state),
|
welcomeVersion: selectWelcomeVersion(state),
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
|
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
|
||||||
import { doResolveUris } from 'redux/actions/claims';
|
import { doResolveUris } from 'redux/actions/claims';
|
||||||
import { selectPendingIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { selectPendingIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { makeSelectWinningUriForQuery, makeSelectIsResolvingWinningUri } from 'redux/selectors/search';
|
import { makeSelectWinningUriForQuery, selectIsResolvingWinningUri } from 'redux/selectors/search';
|
||||||
import SearchTopClaim from './view';
|
import SearchTopClaim from './view';
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
|
@ -13,7 +13,7 @@ const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
winningUri,
|
winningUri,
|
||||||
winningClaim: winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined,
|
winningClaim: winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined,
|
||||||
isResolvingWinningUri: props.query ? makeSelectIsResolvingWinningUri(props.query)(state) : false,
|
isResolvingWinningUri: props.query ? selectIsResolvingWinningUri(state, props.query) : false,
|
||||||
pendingIds: selectPendingIds(state),
|
pendingIds: selectPendingIds(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims';
|
||||||
import SocialShare from './view';
|
import SocialShare from './view';
|
||||||
import { selectUserInviteReferralCode, selectUser } from 'redux/selectors/user';
|
import { selectUserInviteReferralCode, selectUser } from 'redux/selectors/user';
|
||||||
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
|
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
|
||||||
|
@ -8,7 +8,7 @@ const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
referralCode: selectUserInviteReferralCode(state),
|
referralCode: selectUserInviteReferralCode(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
position: makeSelectContentPositionForUri(props.uri)(state),
|
position: makeSelectContentPositionForUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { normalizeURI } from 'util/lbryURI';
|
import { normalizeURI } from 'util/lbryURI';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { makeSelectIsUriResolving, makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { selectIsUriResolving, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import UriIndicator from './view';
|
import UriIndicator from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: selectIsUriResolving(state, props.uri),
|
||||||
uri: normalizeURI(props.uri),
|
uri: normalizeURI(props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
import { selectVolume, selectMute } from 'redux/selectors/app';
|
import { selectVolume, selectMute } from 'redux/selectors/app';
|
||||||
import { savePosition, clearPosition, doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
import { savePosition, clearPosition, doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
||||||
import { makeSelectContentPositionForUri, makeSelectIsPlayerFloating, selectPlayingUri } from 'redux/selectors/content';
|
import { makeSelectContentPositionForUri, makeSelectIsPlayerFloating, selectPlayingUri } from 'redux/selectors/content';
|
||||||
import { makeSelectRecommendedContentForUri } from 'redux/selectors/search';
|
import { selectRecommendedContentForUri } from 'redux/selectors/search';
|
||||||
import VideoViewer from './view';
|
import VideoViewer from './view';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
|
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
|
||||||
|
@ -44,7 +44,7 @@ const select = (state, props) => {
|
||||||
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
|
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
|
||||||
previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
|
previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
|
||||||
} else {
|
} else {
|
||||||
const recommendedContent = makeSelectRecommendedContentForUri(uri)(state);
|
const recommendedContent = selectRecommendedContentForUri(state, uri);
|
||||||
nextRecommendedUri = recommendedContent && recommendedContent[0];
|
nextRecommendedUri = recommendedContent && recommendedContent[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
selectClaimIsMineForUri,
|
selectClaimIsMineForUri,
|
||||||
selectFetchingMyChannels,
|
selectFetchingMyChannels,
|
||||||
|
@ -24,7 +24,7 @@ const select = (state, props) => ({
|
||||||
instantTipEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
|
instantTipEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
|
||||||
instantTipMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
|
instantTipMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
|
||||||
isPending: selectIsSendingSupport(state),
|
isPending: selectIsSendingSupport(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withRouter(connect(select, { doHideModal, doSendTip, doSendCashTip })(WalletSendTip));
|
export default withRouter(connect(select, { doHideModal, doSendTip, doSendCashTip })(WalletSendTip));
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { selectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import WunderbarSuggestion from './view';
|
import WunderbarSuggestion from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: selectClaimForUri(state, props.uri),
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: selectIsUriResolving(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(WunderbarSuggestion);
|
export default connect(select)(WunderbarSuggestion);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
makeSelectTagInClaimOrChannelForUri,
|
makeSelectTagInClaimOrChannelForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { doResolveUris } from 'redux/actions/claims';
|
import { doResolveUris } from 'redux/actions/claims';
|
||||||
|
@ -23,7 +23,7 @@ const select = (state, props) => {
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
const resolvingUris = uris.some((uri) => makeSelectIsUriResolving(uri)(state));
|
const resolvingUris = uris.some((uri) => selectIsUriResolving(state, uri));
|
||||||
const winningUri = makeSelectWinningUriForQuery(props.query)(state);
|
const winningUri = makeSelectWinningUriForQuery(props.query)(state);
|
||||||
const winningClaim = winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined;
|
const winningClaim = winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined;
|
||||||
const preferEmbed = makeSelectTagInClaimOrChannelForUri(winningUri, PREFERENCE_EMBED)(state);
|
const preferEmbed = makeSelectTagInClaimOrChannelForUri(winningUri, PREFERENCE_EMBED)(state);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { MATURE_TAGS } from 'constants/tags';
|
|
||||||
export const MINIMUM_PUBLISH_BID = 0.0001;
|
export const MINIMUM_PUBLISH_BID = 0.0001;
|
||||||
export const ESTIMATED_FEE = 0.048; // .001 + .001 | .048 + .048 = .1
|
export const ESTIMATED_FEE = 0.048; // .001 + .001 | .048 + .048 = .1
|
||||||
|
|
||||||
|
@ -39,68 +38,3 @@ export const FORCE_CONTENT_TYPE_COMIC = [
|
||||||
'application/x-cbz',
|
'application/x-cbz',
|
||||||
'application/x-cb7',
|
'application/x-cb7',
|
||||||
];
|
];
|
||||||
|
|
||||||
const matureTagMap = MATURE_TAGS.reduce((acc, tag) => ({ ...acc, [tag]: true }), {});
|
|
||||||
|
|
||||||
export const isClaimNsfw = (claim: Claim): boolean => {
|
|
||||||
if (!claim) {
|
|
||||||
throw new Error('No claim passed to isClaimNsfw()');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!claim.value) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tags = claim.value.tags || [];
|
|
||||||
for (let i = 0; i < tags.length; i += 1) {
|
|
||||||
const tag = tags[i].toLowerCase();
|
|
||||||
if (matureTagMap[tag]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function createNormalizedClaimSearchKey(options: { page: number, release_time?: string }) {
|
|
||||||
// Ignore page because we don't care what the last page searched was, we want everything
|
|
||||||
// Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567"
|
|
||||||
const { page: optionToIgnoreForQuery, release_time: anotherToIgnore, ...rest } = options;
|
|
||||||
const query = JSON.stringify(rest);
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function concatClaims(claimList: Array<Claim> = [], concatClaimList: Array<any> = []): Array<Claim> {
|
|
||||||
if (!claimList || claimList.length === 0) {
|
|
||||||
if (!concatClaimList) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return concatClaimList.slice();
|
|
||||||
}
|
|
||||||
|
|
||||||
const claims = claimList.slice();
|
|
||||||
concatClaimList.forEach((claim) => {
|
|
||||||
if (!claims.some((item) => item.claim_id === claim.claim_id)) {
|
|
||||||
claims.push(claim);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return claims;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function filterClaims(claims: Array<Claim>, query: ?string): Array<Claim> {
|
|
||||||
if (query) {
|
|
||||||
const queryMatchRegExp = new RegExp(query, 'i');
|
|
||||||
return claims.filter((claim) => {
|
|
||||||
const { value } = claim;
|
|
||||||
|
|
||||||
return (
|
|
||||||
(value.title && value.title.match(queryMatchRegExp)) ||
|
|
||||||
(claim.signing_channel && claim.signing_channel.name.match(queryMatchRegExp)) ||
|
|
||||||
(claim.name && claim.name.match(queryMatchRegExp))
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return claims;
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import ModalPublishPreview from './view';
|
import ModalPublishPreview from './view';
|
||||||
import { makeSelectPublishFormValue, selectPublishFormValues, selectIsStillEditing } from 'redux/selectors/publish';
|
import { makeSelectPublishFormValue, selectPublishFormValues, selectIsStillEditing } from 'redux/selectors/publish';
|
||||||
import { selectMyChannelClaims, makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { selectMyChannelClaims, selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { selectFfmpegStatus, makeSelectClientSetting } from 'redux/selectors/settings';
|
import { selectFfmpegStatus, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { doPublishDesktop } from 'redux/actions/publish';
|
import { doPublishDesktop } from 'redux/actions/publish';
|
||||||
|
@ -21,7 +21,7 @@ const select = (state, props) => {
|
||||||
isStillEditing: selectIsStillEditing(state),
|
isStillEditing: selectIsStillEditing(state),
|
||||||
ffmpegStatus: selectFfmpegStatus(state),
|
ffmpegStatus: selectFfmpegStatus(state),
|
||||||
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
||||||
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(editingUri)(state),
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, editingUri),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doDeleteFileAndMaybeGoBack } from 'redux/actions/file';
|
import { doDeleteFileAndMaybeGoBack } from 'redux/actions/file';
|
||||||
import {
|
import {
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectIsAbandoningClaimForUri,
|
makeSelectIsAbandoningClaimForUri,
|
||||||
selectClaimIsMineForUri,
|
selectClaimIsMineForUri,
|
||||||
|
@ -12,7 +12,7 @@ import ModalRemoveFile from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
isAbandoning: makeSelectIsAbandoningClaimForUri(props.uri)(state),
|
isAbandoning: makeSelectIsAbandoningClaimForUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
getThumbnailFromClaim,
|
getThumbnailFromClaim,
|
||||||
makeSelectCoverForUri,
|
makeSelectCoverForUri,
|
||||||
selectCurrentChannelPage,
|
selectCurrentChannelPage,
|
||||||
|
@ -9,7 +9,7 @@ import {
|
||||||
makeSelectClaimIsPending,
|
makeSelectClaimIsPending,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { selectMyUnpublishedCollections } from 'redux/selectors/collections';
|
import { selectMyUnpublishedCollections } from 'redux/selectors/collections';
|
||||||
import { selectBlackListedOutpoints, doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
|
import { selectBlackListedOutpoints, doFetchSubCount, selectSubCountForUri } from 'lbryinc';
|
||||||
import { selectYoutubeChannels } from 'redux/selectors/user';
|
import { selectYoutubeChannels } from 'redux/selectors/user';
|
||||||
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
||||||
import { selectModerationBlockList } from 'redux/selectors/comments';
|
import { selectModerationBlockList } from 'redux/selectors/comments';
|
||||||
|
@ -21,7 +21,7 @@ const select = (state, props) => {
|
||||||
const claim = selectClaimForUri(state, props.uri);
|
const claim = selectClaimForUri(state, props.uri);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: selectTitleForUri(state, props.uri),
|
||||||
thumbnail: getThumbnailFromClaim(claim),
|
thumbnail: getThumbnailFromClaim(claim),
|
||||||
cover: makeSelectCoverForUri(props.uri)(state),
|
cover: makeSelectCoverForUri(props.uri)(state),
|
||||||
channelIsMine: selectClaimIsMine(state, claim),
|
channelIsMine: selectClaimIsMine(state, claim),
|
||||||
|
@ -29,7 +29,7 @@ const select = (state, props) => {
|
||||||
claim,
|
claim,
|
||||||
isSubscribed: selectIsSubscribedForUri(state, props.uri),
|
isSubscribed: selectIsSubscribedForUri(state, props.uri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
subCount: makeSelectSubCountForUri(props.uri)(state),
|
subCount: selectSubCountForUri(state, props.uri),
|
||||||
pending: makeSelectClaimIsPending(props.uri)(state),
|
pending: makeSelectClaimIsPending(props.uri)(state),
|
||||||
youtubeChannels: selectYoutubeChannels(state),
|
youtubeChannels: selectYoutubeChannels(state),
|
||||||
blockedChannels: selectModerationBlockList(state),
|
blockedChannels: selectModerationBlockList(state),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { connect } from 'react-redux';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import CollectionPage from './view';
|
import CollectionPage from './view';
|
||||||
import {
|
import {
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
getThumbnailFromClaim,
|
getThumbnailFromClaim,
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
makeSelectClaimIsPending,
|
makeSelectClaimIsPending,
|
||||||
|
@ -38,7 +38,7 @@ const select = (state, props) => {
|
||||||
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
||||||
collectionCount: makeSelectCountForCollectionId(collectionId)(state),
|
collectionCount: makeSelectCountForCollectionId(collectionId)(state),
|
||||||
isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
||||||
title: makeSelectTitleForUri(uri)(state),
|
title: selectTitleForUri(state, uri),
|
||||||
thumbnail: getThumbnailFromClaim(claim),
|
thumbnail: getThumbnailFromClaim(claim),
|
||||||
isMyClaim: selectClaimIsMine(state, claim), // or collection is mine?
|
isMyClaim: selectClaimIsMine(state, claim), // or collection is mine?
|
||||||
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import EmbedWrapperPage from './view';
|
import EmbedWrapperPage from './view';
|
||||||
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
|
||||||
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
||||||
import { doResolveUri } from 'redux/actions/claims';
|
import { doResolveUri } from 'redux/actions/claims';
|
||||||
import { buildURI } from 'util/lbryURI';
|
import { buildURI } from 'util/lbryURI';
|
||||||
|
@ -17,7 +17,7 @@ const select = (state, props) => {
|
||||||
claim: makeSelectClaimForUri(uri)(state),
|
claim: makeSelectClaimForUri(uri)(state),
|
||||||
costInfo: makeSelectCostInfoForUri(uri)(state),
|
costInfo: makeSelectCostInfoForUri(uri)(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
||||||
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
isResolvingUri: selectIsUriResolving(state, uri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,9 +2,9 @@ import { connect } from 'react-redux';
|
||||||
import { doSetContentHistoryItem, doSetPrimaryUri, clearPosition } from 'redux/actions/content';
|
import { doSetContentHistoryItem, doSetPrimaryUri, clearPosition } from 'redux/actions/content';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimIsNsfw,
|
selectClaimIsNsfwForUri,
|
||||||
makeSelectTagInClaimOrChannelForUri,
|
makeSelectTagInClaimOrChannelForUri,
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
selectIsStreamPlaceholderForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
||||||
import { doFetchFileInfo } from 'redux/actions/file_info';
|
import { doFetchFileInfo } from 'redux/actions/file_info';
|
||||||
|
@ -27,12 +27,12 @@ const select = (state, props) => {
|
||||||
linkedCommentId: urlParams.get('lc'),
|
linkedCommentId: urlParams.get('lc'),
|
||||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||||
obscureNsfw: !selectShowMatureContent(state),
|
obscureNsfw: !selectShowMatureContent(state),
|
||||||
isMature: makeSelectClaimIsNsfw(props.uri)(state),
|
isMature: selectClaimIsNsfwForUri(state, props.uri),
|
||||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||||
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
||||||
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
||||||
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestream: selectIsStreamPlaceholderForUri(state, props.uri),
|
||||||
collection: makeSelectCollectionForId(collectionId)(state),
|
collection: makeSelectCollectionForId(collectionId)(state),
|
||||||
collectionId,
|
collectionId,
|
||||||
position: makeSelectContentPositionForUri(props.uri)(state),
|
position: makeSelectContentPositionForUri(props.uri)(state),
|
||||||
|
|
|
@ -5,12 +5,12 @@ import { withRouter } from 'react-router';
|
||||||
import { PAGE_SIZE } from 'constants/claim';
|
import { PAGE_SIZE } from 'constants/claim';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
makeSelectTotalPagesForChannel,
|
makeSelectTotalPagesForChannel,
|
||||||
makeSelectTitleForUri,
|
selectTitleForUri,
|
||||||
selectClaimIsMine,
|
selectClaimIsMine,
|
||||||
makeSelectClaimIsPending,
|
makeSelectClaimIsPending,
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
selectIsStreamPlaceholderForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import {
|
import {
|
||||||
makeSelectCollectionForId,
|
makeSelectCollectionForId,
|
||||||
|
@ -72,14 +72,14 @@ const select = (state, props) => {
|
||||||
return {
|
return {
|
||||||
uri,
|
uri,
|
||||||
claim,
|
claim,
|
||||||
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
isResolvingUri: selectIsUriResolving(state, uri),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state),
|
totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state),
|
||||||
isSubscribed: makeSelectChannelInSubscriptions(uri)(state),
|
isSubscribed: makeSelectChannelInSubscriptions(uri)(state),
|
||||||
title: makeSelectTitleForUri(uri)(state),
|
title: selectTitleForUri(state, uri),
|
||||||
claimIsMine: selectClaimIsMine(state, claim),
|
claimIsMine: selectClaimIsMine(state, claim),
|
||||||
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
||||||
isLivestream: makeSelectClaimIsStreamPlaceholder(uri)(state),
|
isLivestream: selectIsStreamPlaceholderForUri(state, uri),
|
||||||
collection: makeSelectCollectionForId(collectionId)(state),
|
collection: makeSelectCollectionForId(collectionId)(state),
|
||||||
collectionId: collectionId,
|
collectionId: collectionId,
|
||||||
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
import { makeSelectClaimForUri, makeSelectClaimIsNsfw } from 'redux/selectors/claims';
|
import { selectClaimForUri, selectClaimIsNsfwForUri } from 'redux/selectors/claims';
|
||||||
import { doResolveUris } from 'redux/actions/claims';
|
import { doResolveUris } from 'redux/actions/claims';
|
||||||
import { buildURI, isURIValid } from 'util/lbryURI';
|
import { buildURI, isURIValid } from 'util/lbryURI';
|
||||||
import { batchActions } from 'util/batch-actions';
|
import { batchActions } from 'util/batch-actions';
|
||||||
|
@ -12,7 +12,7 @@ import { getRecommendationSearchOptions } from 'util/search';
|
||||||
import { SEARCH_SERVER_API } from 'config';
|
import { SEARCH_SERVER_API } from 'config';
|
||||||
|
|
||||||
type Dispatch = (action: any) => any;
|
type Dispatch = (action: any) => any;
|
||||||
type GetState = () => { search: SearchState };
|
type GetState = () => { claims: any, search: SearchState };
|
||||||
|
|
||||||
type SearchOptions = {
|
type SearchOptions = {
|
||||||
size?: number,
|
size?: number,
|
||||||
|
@ -131,9 +131,9 @@ export const doUpdateSearchOptions = (newOptions: SearchOptions, additionalOptio
|
||||||
|
|
||||||
export const doFetchRecommendedContent = (uri: string) => (dispatch: Dispatch, getState: GetState) => {
|
export const doFetchRecommendedContent = (uri: string) => (dispatch: Dispatch, getState: GetState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const claim = makeSelectClaimForUri(uri)(state);
|
const claim = selectClaimForUri(state, uri);
|
||||||
const matureEnabled = selectShowMatureContent(state);
|
const matureEnabled = selectShowMatureContent(state);
|
||||||
const claimIsMature = makeSelectClaimIsNsfw(uri)(state);
|
const claimIsMature = selectClaimIsNsfwForUri(state, uri);
|
||||||
|
|
||||||
if (claim && claim.value && claim.claim_id) {
|
if (claim && claim.value && claim.claim_id) {
|
||||||
const options: SearchOptions = getRecommendationSearchOptions(matureEnabled, claimIsMature, claim.claim_id);
|
const options: SearchOptions = getRecommendationSearchOptions(matureEnabled, claimIsMature, claim.claim_id);
|
||||||
|
|
|
@ -332,10 +332,11 @@ export const makeSelectTotalPagesInChannelSearch = (uri: string) =>
|
||||||
return byChannel['pageCount'];
|
return byChannel['pageCount'];
|
||||||
});
|
});
|
||||||
|
|
||||||
export const selectMetadataForUri = createCachedSelector(selectClaimForUri, (claim, uri) => {
|
export const selectMetadataForUri = (state: State, uri: string) => {
|
||||||
|
const claim = selectClaimForUri(state, uri);
|
||||||
const metadata = claim && claim.value;
|
const metadata = claim && claim.value;
|
||||||
return metadata || (claim === undefined ? undefined : null);
|
return metadata || (claim === undefined ? undefined : null);
|
||||||
})((state, uri) => String(uri));
|
};
|
||||||
|
|
||||||
export const makeSelectMetadataForUri = (uri: string) =>
|
export const makeSelectMetadataForUri = (uri: string) =>
|
||||||
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
||||||
|
@ -348,8 +349,10 @@ export const makeSelectMetadataItemForUri = (uri: string, key: string) =>
|
||||||
return metadata ? metadata[key] : undefined;
|
return metadata ? metadata[key] : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectTitleForUri = (uri: string) =>
|
export const selectTitleForUri = (state: State, uri: string) => {
|
||||||
createSelector(makeSelectMetadataForUri(uri), (metadata) => metadata && metadata.title);
|
const metadata = selectMetadataForUri(state, uri);
|
||||||
|
return metadata && metadata.title;
|
||||||
|
};
|
||||||
|
|
||||||
export const selectDateForUri = createCachedSelector(
|
export const selectDateForUri = createCachedSelector(
|
||||||
selectClaimForUri, // input: (state, uri, ?returnRepost)
|
selectClaimForUri, // input: (state, uri, ?returnRepost)
|
||||||
|
@ -516,8 +519,10 @@ export const selectResolvingUris = createSelector(selectState, (state) => state.
|
||||||
|
|
||||||
export const selectChannelImportPending = (state: State) => selectState(state).pendingChannelImport;
|
export const selectChannelImportPending = (state: State) => selectState(state).pendingChannelImport;
|
||||||
|
|
||||||
export const makeSelectIsUriResolving = (uri: string) =>
|
export const selectIsUriResolving = (state: State, uri: string) => {
|
||||||
createSelector(selectResolvingUris, (resolvingUris) => resolvingUris && resolvingUris.indexOf(uri) !== -1);
|
const resolvingUris = selectResolvingUris(state);
|
||||||
|
return resolvingUris && resolvingUris.includes(uri);
|
||||||
|
};
|
||||||
|
|
||||||
export const selectPlayingUri = (state: State) => selectState(state).playingUri;
|
export const selectPlayingUri = (state: State) => selectState(state).playingUri;
|
||||||
|
|
||||||
|
@ -570,21 +575,16 @@ export const makeSelectOmittedCountForChannel = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectClaimIsNsfw = (uri: string) =>
|
export const selectClaimIsNsfwForUri = createCachedSelector(
|
||||||
createSelector(
|
selectClaimForUri,
|
||||||
makeSelectClaimForUri(uri),
|
// Eventually these will come from some list of tags that are considered adult
|
||||||
// Eventually these will come from some list of tags that are considered adult
|
// Or possibly come from users settings of what tags they want to hide
|
||||||
// Or possibly come from users settings of what tags they want to hide
|
// For now, there is just a hard coded list of tags inside `isClaimNsfw`
|
||||||
// For now, there is just a hard coded list of tags inside `isClaimNsfw`
|
// selectNaughtyTags(),
|
||||||
// selectNaughtyTags(),
|
(claim: Claim) => {
|
||||||
(claim: Claim) => {
|
return claim ? isClaimNsfw(claim) : false;
|
||||||
if (!claim) {
|
}
|
||||||
return false;
|
)((state, uri) => String(uri));
|
||||||
}
|
|
||||||
|
|
||||||
return isClaimNsfw(claim);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Returns the associated channel uri for a given claim uri
|
// Returns the associated channel uri for a given claim uri
|
||||||
// accepts a regular claim uri lbry://something
|
// accepts a regular claim uri lbry://something
|
||||||
|
@ -710,14 +710,14 @@ export const makeSelectClaimHasSource = (uri: string) =>
|
||||||
return Boolean(claim.value.source);
|
return Boolean(claim.value.source);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectClaimIsStreamPlaceholder = (uri: string) =>
|
export const isStreamPlaceholderClaim = (claim: ?StreamClaim) => {
|
||||||
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
return claim ? Boolean(claim.value_type === 'stream' && !claim.value.source) : false;
|
||||||
if (!claim) {
|
};
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Boolean(claim.value_type === 'stream' && !claim.value.source);
|
export const selectIsStreamPlaceholderForUri = (state: State, uri: string) => {
|
||||||
});
|
const claim = selectClaimForUri(state, uri);
|
||||||
|
return isStreamPlaceholderClaim(claim);
|
||||||
|
};
|
||||||
|
|
||||||
export const selectTotalStakedAmountForChannelUri = createCachedSelector(selectClaimForUri, (claim) => {
|
export const selectTotalStakedAmountForChannelUri = createCachedSelector(selectClaimForUri, (claim) => {
|
||||||
if (!claim || !claim.amount || !claim.meta || !claim.meta.support_amount) {
|
if (!claim || !claim.amount || !claim.meta || !claim.meta.support_amount) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
makeSelectClaimIsNsfw,
|
selectClaimIsNsfwForUri,
|
||||||
makeSelectClaimIsMine,
|
makeSelectClaimIsMine,
|
||||||
makeSelectContentTypeForUri,
|
makeSelectContentTypeForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
@ -85,10 +85,11 @@ export const selectRecentHistory = createSelector(selectHistory, (history) => {
|
||||||
return history.slice(0, RECENT_HISTORY_AMOUNT);
|
return history.slice(0, RECENT_HISTORY_AMOUNT);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectShouldObscurePreview = (uri: string) =>
|
export const selectShouldObscurePreviewForUri = (state: State, uri: string) => {
|
||||||
createSelector(selectShowMatureContent, makeSelectClaimIsNsfw(uri), (showMatureContent, isClaimMature) => {
|
const showMatureContent = selectShowMatureContent(state);
|
||||||
return isClaimMature && !showMatureContent;
|
const isClaimMature = selectClaimIsNsfwForUri(state, uri);
|
||||||
});
|
return isClaimMature && !showMatureContent;
|
||||||
|
};
|
||||||
|
|
||||||
// should probably be in lbry-redux, yarn link was fighting me
|
// should probably be in lbry-redux, yarn link was fighting me
|
||||||
export const makeSelectFileExtensionForUri = (uri: string) =>
|
export const makeSelectFileExtensionForUri = (uri: string) =>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import { createCachedSelector } from 're-reselect';
|
||||||
import { selectMyClaims, selectPendingClaims } from 'redux/selectors/claims';
|
import { selectMyClaims, selectPendingClaims } from 'redux/selectors/claims';
|
||||||
|
|
||||||
type State = { livestream: any };
|
type State = { livestream: any };
|
||||||
|
@ -45,20 +46,16 @@ export const makeSelectPendingLivestreamsForChannelId = (channelId: string) =>
|
||||||
|
|
||||||
export const selectActiveLivestreams = (state: State) => selectState(state).activeLivestreams;
|
export const selectActiveLivestreams = (state: State) => selectState(state).activeLivestreams;
|
||||||
|
|
||||||
export const makeSelectIsActiveLivestream = (uri: string) =>
|
export const selectIsActiveLivestreamForUri = createCachedSelector(
|
||||||
createSelector(selectState, (state) => {
|
(state, uri) => uri,
|
||||||
const activeLivestreamValues = (state.activeLivestreams && Object.values(state.activeLivestreams)) || [];
|
selectActiveLivestreams,
|
||||||
// $FlowFixMe
|
(uri, activeLivestreams) => {
|
||||||
return Boolean(activeLivestreamValues.find((v) => v.latestClaimUri === uri));
|
if (!uri || !activeLivestreams) {
|
||||||
});
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export const makeSelectActiveLivestreamUris = (uri: string) =>
|
const activeLivestreamValues = Object.values(activeLivestreams);
|
||||||
createSelector(selectState, (state) => {
|
// $FlowFixMe - unable to resolve latestClaimUri
|
||||||
const activeLivestreamValues = (state.activeLivestreams && Object.values(state.activeLivestreams)) || [];
|
return activeLivestreamValues.some((v) => v.latestClaimUri === uri);
|
||||||
const uris = [];
|
}
|
||||||
activeLivestreamValues.forEach((v) => {
|
)((state, uri) => String(uri));
|
||||||
// $FlowFixMe
|
|
||||||
if (v.latestClaimUri) uris.push(v.latestClaimUri);
|
|
||||||
});
|
|
||||||
return uris;
|
|
||||||
});
|
|
||||||
|
|
|
@ -6,20 +6,21 @@ import {
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectClaimForClaimId,
|
makeSelectClaimForClaimId,
|
||||||
makeSelectClaimIsNsfw,
|
selectClaimIsNsfwForUri,
|
||||||
makeSelectPendingClaimForUri,
|
makeSelectPendingClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
selectIsUriResolving,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { parseURI } from 'util/lbryURI';
|
import { parseURI } from 'util/lbryURI';
|
||||||
import { isClaimNsfw } from 'util/claim';
|
import { isClaimNsfw } from 'util/claim';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import { createCachedSelector } from 're-reselect';
|
||||||
import { createNormalizedSearchKey, getRecommendationSearchOptions } from 'util/search';
|
import { createNormalizedSearchKey, getRecommendationSearchOptions } from 'util/search';
|
||||||
import { selectMutedChannels } from 'redux/selectors/blocked';
|
import { selectMutedChannels } from 'redux/selectors/blocked';
|
||||||
import { selectHistory } from 'redux/selectors/content';
|
import { selectHistory } from 'redux/selectors/content';
|
||||||
import { selectAllCostInfoByUri } from 'lbryinc';
|
import { selectAllCostInfoByUri } from 'lbryinc';
|
||||||
import { SIMPLE_SITE } from 'config';
|
import { SIMPLE_SITE } from 'config';
|
||||||
|
|
||||||
type State = { search: SearchState };
|
type State = { claims: any, search: SearchState };
|
||||||
|
|
||||||
export const selectState = (state: State): SearchState => state.search;
|
export const selectState = (state: State): SearchState => state.search;
|
||||||
|
|
||||||
|
@ -51,98 +52,98 @@ export const makeSelectHasReachedMaxResultsLength = (query: string): ((state: St
|
||||||
return hasReachedMaxResultsLength[query];
|
return hasReachedMaxResultsLength[query];
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectRecommendedContentForUri = (uri: string) =>
|
export const selectRecommendedContentForUri = createCachedSelector(
|
||||||
createSelector(
|
(state, uri) => uri,
|
||||||
selectHistory,
|
selectHistory,
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
selectShowMatureContent,
|
selectShowMatureContent,
|
||||||
selectMutedChannels,
|
selectMutedChannels,
|
||||||
selectAllCostInfoByUri,
|
selectAllCostInfoByUri,
|
||||||
selectSearchResultByQuery,
|
selectSearchResultByQuery,
|
||||||
makeSelectClaimIsNsfw(uri),
|
selectClaimIsNsfwForUri, // (state, uri)
|
||||||
(history, claimsByUri, matureEnabled, blockedChannels, costInfoByUri, searchUrisByQuery, isMature) => {
|
(uri, history, claimsByUri, matureEnabled, blockedChannels, costInfoByUri, searchUrisByQuery, isMature) => {
|
||||||
const claim = claimsByUri[uri];
|
const claim = claimsByUri[uri];
|
||||||
|
|
||||||
if (!claim) return;
|
if (!claim) return;
|
||||||
|
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
// always grab the claimId - this value won't change for filtering
|
// always grab the claimId - this value won't change for filtering
|
||||||
const currentClaimId = claim.claim_id;
|
const currentClaimId = claim.claim_id;
|
||||||
|
|
||||||
const { title } = claim.value;
|
const { title } = claim.value;
|
||||||
|
|
||||||
if (!title) return;
|
if (!title) return;
|
||||||
|
|
||||||
const options: {
|
const options: {
|
||||||
size: number,
|
size: number,
|
||||||
nsfw?: boolean,
|
nsfw?: boolean,
|
||||||
isBackgroundSearch?: boolean,
|
isBackgroundSearch?: boolean,
|
||||||
} = { size: 20, nsfw: matureEnabled, isBackgroundSearch: true };
|
} = { size: 20, nsfw: matureEnabled, isBackgroundSearch: true };
|
||||||
|
|
||||||
if (SIMPLE_SITE) {
|
if (SIMPLE_SITE) {
|
||||||
options[SEARCH_OPTIONS.CLAIM_TYPE] = SEARCH_OPTIONS.INCLUDE_FILES;
|
options[SEARCH_OPTIONS.CLAIM_TYPE] = SEARCH_OPTIONS.INCLUDE_FILES;
|
||||||
options[SEARCH_OPTIONS.MEDIA_VIDEO] = true;
|
options[SEARCH_OPTIONS.MEDIA_VIDEO] = true;
|
||||||
options[SEARCH_OPTIONS.PRICE_FILTER_FREE] = true;
|
options[SEARCH_OPTIONS.PRICE_FILTER_FREE] = true;
|
||||||
}
|
|
||||||
if (matureEnabled || (!matureEnabled && !isMature)) {
|
|
||||||
options[SEARCH_OPTIONS.RELATED_TO] = claim.claim_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
|
||||||
const normalizedSearchQuery = createNormalizedSearchKey(searchQuery);
|
|
||||||
|
|
||||||
let searchResult = searchUrisByQuery[normalizedSearchQuery];
|
|
||||||
|
|
||||||
if (searchResult) {
|
|
||||||
// Filter from recommended: The same claim and blocked channels
|
|
||||||
recommendedContent = searchResult['uris'].filter((searchUri) => {
|
|
||||||
const searchClaim = claimsByUri[searchUri];
|
|
||||||
|
|
||||||
if (!searchClaim) return;
|
|
||||||
|
|
||||||
const signingChannel = searchClaim && searchClaim.signing_channel;
|
|
||||||
const channelUri = signingChannel && signingChannel.canonical_url;
|
|
||||||
const blockedMatch = blockedChannels.some((blockedUri) => blockedUri.includes(channelUri));
|
|
||||||
|
|
||||||
let isEqualUri;
|
|
||||||
try {
|
|
||||||
const { claimId: searchId } = parseURI(searchUri);
|
|
||||||
isEqualUri = searchId === currentClaimId;
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
return !isEqualUri && !blockedMatch;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Claim to play next: playable and free claims not played before in history
|
|
||||||
const nextUriToPlay = recommendedContent.filter((nextRecommendedUri) => {
|
|
||||||
const costInfo = costInfoByUri[nextRecommendedUri] && costInfoByUri[nextRecommendedUri].cost;
|
|
||||||
const recommendedClaim = claimsByUri[nextRecommendedUri];
|
|
||||||
const isVideo = recommendedClaim && recommendedClaim.value && recommendedClaim.value.stream_type === 'video';
|
|
||||||
const isAudio = recommendedClaim && recommendedClaim.value && recommendedClaim.value.stream_type === 'audio';
|
|
||||||
|
|
||||||
let historyMatch = false;
|
|
||||||
try {
|
|
||||||
const { claimId: nextRecommendedId } = parseURI(nextRecommendedUri);
|
|
||||||
|
|
||||||
historyMatch = history.some(
|
|
||||||
(historyItem) =>
|
|
||||||
(claimsByUri[historyItem.uri] && claimsByUri[historyItem.uri].claim_id) === nextRecommendedId
|
|
||||||
);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
return !historyMatch && costInfo === 0 && (isVideo || isAudio);
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
const index = recommendedContent.indexOf(nextUriToPlay);
|
|
||||||
if (index > 0) {
|
|
||||||
const a = recommendedContent[0];
|
|
||||||
recommendedContent[0] = nextUriToPlay;
|
|
||||||
recommendedContent[index] = a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return recommendedContent;
|
|
||||||
}
|
}
|
||||||
);
|
if (matureEnabled || (!matureEnabled && !isMature)) {
|
||||||
|
options[SEARCH_OPTIONS.RELATED_TO] = claim.claim_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
||||||
|
const normalizedSearchQuery = createNormalizedSearchKey(searchQuery);
|
||||||
|
|
||||||
|
let searchResult = searchUrisByQuery[normalizedSearchQuery];
|
||||||
|
|
||||||
|
if (searchResult) {
|
||||||
|
// Filter from recommended: The same claim and blocked channels
|
||||||
|
recommendedContent = searchResult['uris'].filter((searchUri) => {
|
||||||
|
const searchClaim = claimsByUri[searchUri];
|
||||||
|
|
||||||
|
if (!searchClaim) return;
|
||||||
|
|
||||||
|
const signingChannel = searchClaim && searchClaim.signing_channel;
|
||||||
|
const channelUri = signingChannel && signingChannel.canonical_url;
|
||||||
|
const blockedMatch = blockedChannels.some((blockedUri) => blockedUri.includes(channelUri));
|
||||||
|
|
||||||
|
let isEqualUri;
|
||||||
|
try {
|
||||||
|
const { claimId: searchId } = parseURI(searchUri);
|
||||||
|
isEqualUri = searchId === currentClaimId;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return !isEqualUri && !blockedMatch;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Claim to play next: playable and free claims not played before in history
|
||||||
|
const nextUriToPlay = recommendedContent.filter((nextRecommendedUri) => {
|
||||||
|
const costInfo = costInfoByUri[nextRecommendedUri] && costInfoByUri[nextRecommendedUri].cost;
|
||||||
|
const recommendedClaim = claimsByUri[nextRecommendedUri];
|
||||||
|
const isVideo = recommendedClaim && recommendedClaim.value && recommendedClaim.value.stream_type === 'video';
|
||||||
|
const isAudio = recommendedClaim && recommendedClaim.value && recommendedClaim.value.stream_type === 'audio';
|
||||||
|
|
||||||
|
let historyMatch = false;
|
||||||
|
try {
|
||||||
|
const { claimId: nextRecommendedId } = parseURI(nextRecommendedUri);
|
||||||
|
|
||||||
|
historyMatch = history.some(
|
||||||
|
(historyItem) =>
|
||||||
|
(claimsByUri[historyItem.uri] && claimsByUri[historyItem.uri].claim_id) === nextRecommendedId
|
||||||
|
);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return !historyMatch && costInfo === 0 && (isVideo || isAudio);
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
const index = recommendedContent.indexOf(nextUriToPlay);
|
||||||
|
if (index > 0) {
|
||||||
|
const a = recommendedContent[0];
|
||||||
|
recommendedContent[0] = nextUriToPlay;
|
||||||
|
recommendedContent[index] = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return recommendedContent;
|
||||||
|
}
|
||||||
|
)((state, uri) => String(uri));
|
||||||
|
|
||||||
export const makeSelectRecommendedRecsysIdForClaimId = (claimId: string) =>
|
export const makeSelectRecommendedRecsysIdForClaimId = (claimId: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
@ -234,7 +235,7 @@ export const makeSelectWinningUriForQuery = (query: string) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const makeSelectIsResolvingWinningUri = (query: string = '') => {
|
export const selectIsResolvingWinningUri = (state: State, query: string = '') => {
|
||||||
const uriFromQuery = `lbry://${query}`;
|
const uriFromQuery = `lbry://${query}`;
|
||||||
let channelUriFromQuery;
|
let channelUriFromQuery;
|
||||||
try {
|
try {
|
||||||
|
@ -244,13 +245,9 @@ export const makeSelectIsResolvingWinningUri = (query: string = '') => {
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
return createSelector(
|
const claim1IsResolving = selectIsUriResolving(state, uriFromQuery);
|
||||||
makeSelectIsUriResolving(uriFromQuery),
|
const claim2IsResolving = channelUriFromQuery ? selectIsUriResolving(state, channelUriFromQuery) : false;
|
||||||
channelUriFromQuery ? makeSelectIsUriResolving(channelUriFromQuery) : () => {},
|
return claim1IsResolving || claim2IsResolving;
|
||||||
(claim1IsResolving, claim2IsResolving) => {
|
|
||||||
return claim1IsResolving || claim2IsResolving;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const makeSelectUrlForClaimId = (claimId: string) =>
|
export const makeSelectUrlForClaimId = (claimId: string) =>
|
||||||
|
|
|
@ -15,13 +15,19 @@ export const selectFindingFFmpeg = (state) => selectState(state).findingFFmpeg |
|
||||||
export const selectClientSettings = (state) => selectState(state).clientSettings || {};
|
export const selectClientSettings = (state) => selectState(state).clientSettings || {};
|
||||||
export const selectLoadedLanguages = (state) => selectState(state).loadedLanguages || {};
|
export const selectLoadedLanguages = (state) => selectState(state).loadedLanguages || {};
|
||||||
|
|
||||||
|
export const selectClientSetting = (state, setting) => {
|
||||||
|
const clientSettings = selectClientSettings(state);
|
||||||
|
return clientSettings ? clientSettings[setting] : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO - kill this
|
||||||
export const makeSelectClientSetting = (setting) =>
|
export const makeSelectClientSetting = (setting) =>
|
||||||
createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined));
|
createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined));
|
||||||
|
|
||||||
// refactor me
|
// refactor me
|
||||||
export const selectShowMatureContent = !ENABLE_MATURE
|
export const selectShowMatureContent = (state) => {
|
||||||
? createSelector(() => false)
|
return !ENABLE_MATURE ? false : selectClientSetting(state, SETTINGS.SHOW_MATURE);
|
||||||
: makeSelectClientSetting(SETTINGS.SHOW_MATURE);
|
};
|
||||||
|
|
||||||
// and me
|
// and me
|
||||||
export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS);
|
export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectTheme } from 'redux/selectors/settings';
|
import { selectTheme } from 'redux/selectors/settings';
|
||||||
import { makeSelectClaimForUri, makeSelectClaimIsNsfw } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri, selectClaimIsNsfwForUri } from 'redux/selectors/claims';
|
||||||
import Ads from './view';
|
import Ads from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
theme: selectTheme(state),
|
theme: selectTheme(state),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
isMature: makeSelectClaimIsNsfw(props.uri)(state),
|
isMature: selectClaimIsNsfwForUri(state, props.uri),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(Ads);
|
export default connect(select)(Ads);
|
||||||
|
|
Loading…
Reference in a new issue