Fix selectCommentIdsForUri
- memo not required. - start to not use the confusing and wrongly-named 'selectCommentsByUri' (per comment from Sean); use the existing 'selectClaimIdForUri' instead. This works because currently we do fetch any comments without first visiting a claim/uri, so we'll always have fetched the required claim, and can be queried in 'selectClaimIdForUri'.
This commit is contained in:
parent
81d77da17e
commit
d211450b5b
2 changed files with 10 additions and 9 deletions
|
@ -15,7 +15,7 @@ import {
|
|||
makeSelectTotalCommentsCountForUri,
|
||||
selectOthersReacts,
|
||||
selectMyReacts,
|
||||
makeSelectCommentIdsForUri,
|
||||
selectCommentIdsForUri,
|
||||
selectSettingsByChannelId,
|
||||
selectPinnedCommentsForUri,
|
||||
} from 'redux/selectors/comments';
|
||||
|
@ -36,7 +36,7 @@ const select = (state, props) => {
|
|||
topLevelComments,
|
||||
resolvedComments,
|
||||
myChannelIds: selectMyClaimIdsRaw(state),
|
||||
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
|
||||
allCommentIds: selectCommentIdsForUri(state, props.uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
||||
|
|
|
@ -4,14 +4,15 @@ import { createCachedSelector } from 're-reselect';
|
|||
import { selectMutedChannels } from 'redux/selectors/blocked';
|
||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
|
||||
import { selectClaimsById, selectMyClaimIdsRaw } from 'redux/selectors/claims';
|
||||
import { selectClaimsById, selectMyClaimIdsRaw, selectClaimIdForUri } from 'redux/selectors/claims';
|
||||
import { isClaimNsfw } from 'util/claim';
|
||||
|
||||
type State = { comments: CommentsState };
|
||||
type State = { claims: any, comments: CommentsState };
|
||||
|
||||
const selectState = (state) => state.comments || {};
|
||||
|
||||
export const selectCommentsById = (state: State) => selectState(state).commentById || {};
|
||||
export const selectCommentIdsByClaimId = (state: State) => selectState(state).byId;
|
||||
export const selectIsFetchingComments = (state: State) => selectState(state).isLoading;
|
||||
export const selectIsFetchingCommentsById = (state: State) => selectState(state).isLoadingById;
|
||||
export const selectIsFetchingCommentsByParentId = (state: State) => selectState(state).isLoadingByParentId;
|
||||
|
@ -172,11 +173,11 @@ export const selectRepliesByParentId = createSelector(selectState, selectComment
|
|||
|
||||
export const selectLinkedCommentAncestors = (state: State) => selectState(state).linkedCommentAncestors;
|
||||
|
||||
export const makeSelectCommentIdsForUri = (uri: string) =>
|
||||
createSelector(selectState, selectCommentsByUri, selectClaimsById, (state, byUri) => {
|
||||
const claimId = byUri[uri];
|
||||
return state.byId[claimId];
|
||||
});
|
||||
export const selectCommentIdsForUri = (state: State, uri: string) => {
|
||||
const claimId = selectClaimIdForUri(state, uri);
|
||||
const commentIdsByClaimId = selectCommentIdsByClaimId(state);
|
||||
return commentIdsByClaimId[claimId];
|
||||
};
|
||||
|
||||
const filterCommentsDepOnList = {
|
||||
claimsById: selectClaimsById,
|
||||
|
|
Loading…
Reference in a new issue