Simplify 'selectClaimIdForUri'

Memoization is not needed. But note that it is now a 2 parameter selector.
This commit is contained in:
infinite-persistence 2021-11-09 20:23:09 +08:00
parent ece2312ec5
commit 7cefb0fadc
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
4 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { makeSelectClaimIdForUri } from 'redux/selectors/claims';
import { selectClaimIdForUri } from 'redux/selectors/claims';
import {
doCommentModUnBlock,
doCommentModBlock,
@ -43,7 +43,7 @@ const select = (state, props) => {
isBlocked,
isToggling,
isBlockingOrUnBlocking: makeSelectUriIsBlockingOrUnBlocking(props.uri)(state),
creatorId: makeSelectClaimIdForUri(props.creatorUri)(state),
creatorId: selectClaimIdForUri(state, props.creatorUri),
};
};

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { makeSelectIsUriResolving, makeSelectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
import { makeSelectIsUriResolving, selectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
import {
makeSelectUrlsForCollectionId,
makeSelectNameForCollectionId,
@ -10,7 +10,7 @@ import { doFetchItemsInCollection } from 'redux/actions/collections';
import CollectionPreviewOverlay from './view';
const select = (state, props) => {
const collectionId = props.collectionId || (props.uri && makeSelectClaimIdForUri(props.uri));
const collectionId = props.collectionId || (props.uri && selectClaimIdForUri(state, props.uri));
const claim = props.collectionId && makeSelectClaimForClaimId(props.collectionId)(state);
const collectionUri = props.uri || (claim && (claim.canonical_url || claim.permanent_url)) || null;

View file

@ -5,7 +5,7 @@ import {
makeSelectTitleForUri,
makeSelectChannelForClaimUri,
makeSelectClaimIsNsfw,
makeSelectClaimIdForUri,
selectClaimIdForUri,
makeSelectClaimForClaimId,
} from 'redux/selectors/claims';
import {
@ -24,7 +24,7 @@ import { selectShowMatureContent } from 'redux/selectors/settings';
import CollectionPreviewTile from './view';
const select = (state, props) => {
const collectionId = props.collectionId || (props.uri && makeSelectClaimIdForUri(props.uri));
const collectionId = props.collectionId || (props.uri && selectClaimIdForUri(state, props.uri));
const claim = props.collectionId && makeSelectClaimForClaimId(props.collectionId)(state);
const collectionUri = props.uri || (claim && (claim.canonical_url || claim.permanent_url)) || null;

View file

@ -79,8 +79,7 @@ export const makeSelectClaimIdIsPending = (claimId: string) =>
return Boolean(pendingById[claimId]);
});
export const makeSelectClaimIdForUri = (uri: string) =>
createSelector(selectClaimIdsByUri, (claimIds) => claimIds[uri]);
export const selectClaimIdForUri = (state: State, uri: string) => selectClaimIdsByUri(state)[uri];
export const selectReflectingById = (state: State) => selectState(state).reflectingById;