selectClaimIsMineForUri
to replace makeSelectClaimIsMine
## Issue `normalizeUri` | `parseURI` is expensive and has been causing sluggish operations when called repeatedly or within a loop. ## Change Since I'm not confident enough to remove the call entirely from makeSelectClaimIsMine (although I've yet to find a scenario that the uri is not already normalized), we'll try caching the calls instead. ## Results - in a simple test of toggling between 2 category pages, we saved 20ms from `parseURI` calls alone. - in a test of opening all categories one time, the memory usage remained similar. This makes sense since we removed a `makeSelect*` (which creates a selector for each call + not memoizing), and replaced that with a cached selector that's actually memoizing.
This commit is contained in:
parent
97b9b733c6
commit
ece2312ec5
28 changed files with 92 additions and 58 deletions
|
@ -3,7 +3,7 @@ import { PAGE_SIZE } from 'constants/claim';
|
|||
import {
|
||||
makeSelectClaimsInChannelForPage,
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectTotalPagesInChannelSearch,
|
||||
makeSelectClaimForUri,
|
||||
} from 'redux/selectors/claims';
|
||||
|
@ -24,7 +24,7 @@ const select = (state, props) => {
|
|||
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
|
||||
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
|
||||
channelIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
channelIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
|
||||
claim: props.uri && makeSelectClaimForUri(props.uri)(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimForUri, makeSelectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import { doCollectionEdit, doFetchItemsInCollection } from 'redux/actions/collections';
|
||||
import { doPrepareEdit } from 'redux/actions/publish';
|
||||
import {
|
||||
|
@ -51,7 +51,7 @@ const select = (state, props) => {
|
|||
contentClaim,
|
||||
contentSigningChannel,
|
||||
contentChannelUri,
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
hasClaimInWatchLater: makeSelectCollectionForIdHasClaimUrl(
|
||||
COLLECTIONS_CONSTS.WATCH_LATER_ID,
|
||||
contentPermanentUri
|
||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
|||
import {
|
||||
selectClaimForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectClaimIsNsfw,
|
||||
makeSelectReflectingClaimForUri,
|
||||
|
@ -42,7 +42,7 @@ const select = (state, props) => {
|
|||
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
|
||||
reflectingProgress: props.uri && makeSelectReflectingClaimForUri(props.uri)(state),
|
||||
obscureNsfw: selectShowMatureContent(state) === false,
|
||||
claimIsMine: props.uri && makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: props.uri && selectClaimIsMineForUri(state, props.uri),
|
||||
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
|
||||
isResolvingRepost: props.uri && makeSelectIsUriResolving(props.repostUrl)(state),
|
||||
nsfw: props.uri && makeSelectClaimIsNsfw(props.uri)(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { makeSelectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import ClaimPreviewReset from './view';
|
||||
|
||||
|
@ -9,7 +9,7 @@ const select = (state, props) => {
|
|||
return {
|
||||
channelName,
|
||||
channelId,
|
||||
claimIsMine: props.uri && makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: props.uri && selectClaimIsMineForUri(state, props.uri),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
||||
import ClaimProperties from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
});
|
||||
|
||||
export default connect(select, null)(ClaimProperties);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import CollectionContent from './view';
|
||||
import { makeSelectClaimForUri, makeSelectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import {
|
||||
makeSelectUrlsForCollectionId,
|
||||
makeSelectNameForCollectionId,
|
||||
|
@ -24,7 +24,7 @@ const select = (state, props) => {
|
|||
collection: makeSelectCollectionForId(props.id)(state),
|
||||
collectionUrls: makeSelectUrlsForCollectionId(props.id)(state),
|
||||
collectionName: makeSelectNameForCollectionId(props.id)(state),
|
||||
isMine: makeSelectClaimIsMine(url)(state),
|
||||
isMine: selectClaimIsMineForUri(state, url),
|
||||
loop,
|
||||
shuffle,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
selectHasChannels,
|
||||
selectFetchingMyChannels,
|
||||
makeSelectTagInClaimOrChannelForUri,
|
||||
|
@ -18,7 +18,7 @@ const select = (state, props) => ({
|
|||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
hasChannels: selectHasChannels(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
isFetchingChannels: selectFetchingMyChannels(state),
|
||||
settingsByChannelId: selectSettingsByChannelId(state),
|
||||
supportDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_SUPPORT_TAG)(state),
|
||||
|
|
|
@ -4,7 +4,7 @@ import { doCommentPin, doCommentModAddDelegate } from 'redux/actions/comments';
|
|||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { selectModerationDelegatorsById } from 'redux/selectors/comments';
|
||||
import { selectPlayingUri } from 'redux/selectors/content';
|
||||
|
@ -12,7 +12,7 @@ import CommentMenuList from './view';
|
|||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
moderationDelegatorsById: selectModerationDelegatorsById(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import Comment from './view';
|
||||
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { doResolveUri } from 'redux/actions/claims';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { selectMyReactsForComment, selectOthersReactsForComment } from 'redux/selectors/comments';
|
||||
|
@ -14,7 +14,7 @@ const select = (state, props) => {
|
|||
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
myReacts: selectMyReactsForComment(state, reactionKey),
|
||||
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
||||
activeChannelId,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
|||
import { doResolveUris } from 'redux/actions/claims';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
selectFetchingMyChannels,
|
||||
selectMyClaimIdsRaw,
|
||||
} from 'redux/selectors/claims';
|
||||
|
@ -41,7 +41,7 @@ const select = (state, props) => {
|
|||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
isFetchingComments: selectIsFetchingComments(state),
|
||||
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
||||
isFetchingReacts: selectIsFetchingReacts(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doResolveUris } from 'redux/actions/claims';
|
||||
import { makeSelectClaimIsMine, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import CommentsReplies from './view';
|
||||
|
@ -15,7 +15,7 @@ const select = (state, props) => {
|
|||
return {
|
||||
fetchedReplies,
|
||||
resolvedReplies,
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||
myChannelIds: selectMyChannelClaimIds(state),
|
||||
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectClaimForUri,
|
||||
selectHasChannels,
|
||||
makeSelectClaimIsStreamPlaceholder,
|
||||
|
@ -19,7 +19,7 @@ import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
|||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectClaimIsMine,
|
||||
} from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, makeSelectMetadataForUri, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import { makeSelectPendingAmountByUri } from 'redux/selectors/wallet';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
|
@ -11,7 +7,7 @@ import FileDescription from './view';
|
|||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
user: selectUser(state),
|
||||
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimIsMine, makeSelectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
||||
import {
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectDownloadingForUri,
|
||||
|
@ -15,7 +15,7 @@ const select = (state, props) => ({
|
|||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
downloading: makeSelectDownloadingForUri(props.uri)(state),
|
||||
loading: makeSelectLoadingForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimForUri, makeSelectClaimWasPurchased, makeSelectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, makeSelectClaimWasPurchased, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import { makeSelectCostInfoForUri, doFetchCostInfoForUri, makeSelectFetchingCostInfoForUri } from 'lbryinc';
|
||||
import FilePrice from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
fetching: makeSelectFetchingCostInfoForUri(props.uri)(state),
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
makeSelectClaimForUri,
|
||||
makeSelectContentTypeForUri,
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
} from 'redux/selectors/claims';
|
||||
import { makeSelectPendingAmountByUri } from 'redux/selectors/wallet';
|
||||
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
||||
|
@ -19,7 +19,7 @@ const select = (state, props) => ({
|
|||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
user: selectUser(state),
|
||||
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimForUri, makeSelectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, selectClaimIsMineForUri } from 'redux/selectors/claims';
|
||||
import PostViewer from './view';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
});
|
||||
|
||||
export default connect(select, {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectClaimForUri,
|
||||
|
@ -18,7 +18,7 @@ const select = (state, props) => {
|
|||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
|
||||
channelIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
channelIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { makeSelectFilePartlyDownloaded } from 'redux/selectors/file_info';
|
||||
import { makeSelectEditedCollectionForId } from 'redux/selectors/collections';
|
||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
||||
|
@ -13,7 +13,7 @@ const select = (state, props) => {
|
|||
editedCollection: makeSelectEditedCollectionForId(claimId)(state),
|
||||
downloaded: makeSelectFilePartlyDownloaded(props.uri)(state),
|
||||
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
|||
import {
|
||||
makeSelectTitleForUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
selectFetchingMyChannels,
|
||||
} from 'redux/selectors/claims';
|
||||
import { doHideModal } from 'redux/actions/app';
|
||||
|
@ -18,7 +18,7 @@ const select = (state, props) => ({
|
|||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
balance: selectBalance(state),
|
||||
claim: makeSelectClaimForUri(props.uri, false)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
fetchingChannels: selectFetchingMyChannels(state),
|
||||
incognito: selectIncognito(state),
|
||||
instantTipEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectIsAbandoningClaimForUri,
|
||||
makeSelectClaimForClaimId,
|
||||
} from 'redux/selectors/claims';
|
||||
|
@ -15,7 +15,7 @@ const select = (state, props) => {
|
|||
return {
|
||||
claim,
|
||||
uri,
|
||||
claimIsMine: makeSelectClaimIsMine(uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, uri),
|
||||
isAbandoning: makeSelectIsAbandoningClaimForUri(uri)(state),
|
||||
collectionName: makeSelectNameForCollectionId(props.collectionId)(state),
|
||||
};
|
||||
|
|
|
@ -4,14 +4,14 @@ import {
|
|||
makeSelectTitleForUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectIsAbandoningClaimForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
} from 'redux/selectors/claims';
|
||||
import { doResolveUri } from 'redux/actions/claims';
|
||||
import { doHideModal } from 'redux/actions/app';
|
||||
import ModalRemoveFile from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isAbandoning: makeSelectIsAbandoningClaimForUri(props.uri)(state),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectCoverForUri,
|
||||
|
@ -21,7 +21,7 @@ const select = (state, props) => ({
|
|||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
cover: makeSelectCoverForUri(props.uri)(state),
|
||||
channelIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
channelIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
page: selectCurrentChannelPage(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isSubscribed: makeSelectIsSubscribed(props.uri, true)(state),
|
||||
|
|
|
@ -5,7 +5,7 @@ import CollectionPage from './view';
|
|||
import {
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectClaimForClaimId,
|
||||
makeSelectChannelForClaimUri,
|
||||
|
@ -40,7 +40,7 @@ const select = (state, props) => {
|
|||
isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
||||
title: makeSelectTitleForUri(uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(uri)(state),
|
||||
isMyClaim: makeSelectClaimIsMine(uri)(state), // or collection is mine?
|
||||
isMyClaim: selectClaimIsMineForUri(state, uri), // or collection is mine?
|
||||
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
||||
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
||||
collectionHasEdits: Boolean(makeSelectEditedCollectionForId(collectionId)(state)),
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
makeSelectIsUriResolving,
|
||||
makeSelectTotalPagesForChannel,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectClaimIsMine,
|
||||
selectClaimIsMineForUri,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectClaimIsStreamPlaceholder,
|
||||
} from 'redux/selectors/claims';
|
||||
|
@ -77,7 +77,7 @@ const select = (state, props) => {
|
|||
totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state),
|
||||
isSubscribed: makeSelectChannelInSubscriptions(uri)(state),
|
||||
title: makeSelectTitleForUri(uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, uri),
|
||||
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
||||
isLivestream: makeSelectClaimIsStreamPlaceholder(uri)(state),
|
||||
collection: makeSelectCollectionForId(collectionId)(state),
|
||||
|
|
|
@ -12,7 +12,7 @@ import * as SHARED_PREFERENCES from 'constants/shared_preferences';
|
|||
import { DOMAIN, SIMPLE_SITE } from 'config';
|
||||
import Lbry from 'lbry';
|
||||
import { doFetchChannelListMine, doFetchCollectionListMine, doCheckPendingClaims } from 'redux/actions/claims';
|
||||
import { makeSelectClaimForUri, makeSelectClaimIsMine, selectMyChannelClaims } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, selectClaimIsMineForUri, selectMyChannelClaims } from 'redux/selectors/claims';
|
||||
import { doFetchFileInfos } from 'redux/actions/file_info';
|
||||
import { doClearSupport, doBalanceSubscribe } from 'redux/actions/wallet';
|
||||
import { doClearPublish } from 'redux/actions/publish';
|
||||
|
@ -470,7 +470,7 @@ export function doAnalyticsView(uri, timeToStart) {
|
|||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const { txid, nout, claim_id: claimId } = makeSelectClaimForUri(uri)(state);
|
||||
const claimIsMine = makeSelectClaimIsMine(uri)(state);
|
||||
const claimIsMine = selectClaimIsMineForUri(state, uri);
|
||||
const outpoint = `${txid}:${nout}`;
|
||||
|
||||
if (claimIsMine) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as MODALS from 'constants/modal_types';
|
|||
import { ipcRenderer } from 'electron';
|
||||
// @endif
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { makeSelectClaimForUri, makeSelectClaimIsMine, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
||||
import { makeSelectClaimForUri, selectClaimIsMineForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
||||
import {
|
||||
makeSelectFileInfoForUri,
|
||||
selectFileInfosByOutpoint,
|
||||
|
@ -151,7 +151,7 @@ export function doPlayUri(
|
|||
) {
|
||||
return (dispatch: Dispatch, getState: () => any) => {
|
||||
const state = getState();
|
||||
const isMine = makeSelectClaimIsMine(uri)(state);
|
||||
const isMine = selectClaimIsMineForUri(state, uri);
|
||||
const fileInfo = makeSelectFileInfoForUri(uri)(state);
|
||||
const uriIsStreamable = makeSelectUriIsStreamable(uri)(state);
|
||||
const downloadingByOutpoint = selectDownloadingByOutpoint(state);
|
||||
|
|
|
@ -199,6 +199,44 @@ export const selectMyActiveClaims = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
// Helper for 'selectClaimIsMineForUri'.
|
||||
// Returns undefined string if unable to normalize or is not valid.
|
||||
const selectNormalizedAndVerifiedUri = createCachedSelector(
|
||||
(state, rawUri) => rawUri,
|
||||
(rawUri) => {
|
||||
try {
|
||||
const uri = normalizeURI(rawUri);
|
||||
if (isURIValid(uri, false)) {
|
||||
return uri;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
)((state, rawUri) => String(rawUri));
|
||||
|
||||
export const selectClaimIsMineForUri = (state: State, rawUri: string) => {
|
||||
// Not memoizing this selector because:
|
||||
// (1) The workload is somewhat lightweight.
|
||||
// (2) Since it depends on 'selectClaimsByUri', memoization won't work anyway
|
||||
// because the array is constantly invalidated.
|
||||
|
||||
const uri = selectNormalizedAndVerifiedUri(state, rawUri);
|
||||
if (!uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const claimsByUri = selectClaimsByUri(state);
|
||||
const myActiveClaims = selectMyActiveClaims(state);
|
||||
|
||||
return (
|
||||
claimsByUri &&
|
||||
claimsByUri[uri] &&
|
||||
(claimsByUri[uri].is_my_output || (claimsByUri[uri].claim_id && myActiveClaims.has(claimsByUri[uri].claim_id)))
|
||||
);
|
||||
};
|
||||
|
||||
// DEPRECATED - use selectClaimIsMineForUri instead.
|
||||
export const makeSelectClaimIsMine = (rawUri: string) => {
|
||||
let uri;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue