Don't use the obsolete selectCommentsByUri

- Same reason as d211450b.
- Also removed an unused selector.
This commit is contained in:
infinite-persistence 2021-11-17 15:36:04 +08:00
parent 51546436ce
commit e6caa8c7ff
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -51,12 +51,11 @@ export const selectCommentsByUri = createSelector(selectState, (state) => {
export const selectPinnedCommentsById = (state: State) => selectState(state).pinnedCommentsById; export const selectPinnedCommentsById = (state: State) => selectState(state).pinnedCommentsById;
export const selectPinnedCommentsForUri = createCachedSelector( export const selectPinnedCommentsForUri = createCachedSelector(
selectCommentsByUri, selectClaimIdForUri,
selectCommentsById, selectCommentsById,
selectPinnedCommentsById, selectPinnedCommentsById,
(state, uri) => uri, (state, uri) => uri,
(byUri, byId, pinnedCommentsById, uri) => { (claimId, byId, pinnedCommentsById, uri) => {
const claimId = byUri[uri];
const pinnedCommentIds = pinnedCommentsById && pinnedCommentsById[claimId]; const pinnedCommentIds = pinnedCommentsById && pinnedCommentsById[claimId];
const pinnedComments = []; const pinnedComments = [];
@ -199,10 +198,9 @@ export const selectFetchingBlockedWords = (state: State) => selectState(state).f
export const selectCommentsForUri = createCachedSelector( export const selectCommentsForUri = createCachedSelector(
(state, uri) => uri, (state, uri) => uri,
selectCommentsByClaimId, selectCommentsByClaimId,
selectCommentsByUri, selectClaimIdForUri,
...Object.values(filterCommentsDepOnList), ...Object.values(filterCommentsDepOnList),
(uri, byClaimId, byUri, ...filterInputs) => { (uri, byClaimId, claimId, ...filterInputs) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId]; const comments = byClaimId && byClaimId[claimId];
return filterComments(comments, claimId, filterInputs); return filterComments(comments, claimId, filterInputs);
} }
@ -212,22 +210,15 @@ export const selectTopLevelCommentsForUri = createCachedSelector(
(state, uri) => uri, (state, uri) => uri,
(state, uri, maxCount) => maxCount, (state, uri, maxCount) => maxCount,
selectTopLevelCommentsByClaimId, selectTopLevelCommentsByClaimId,
selectCommentsByUri, selectClaimIdForUri,
...Object.values(filterCommentsDepOnList), ...Object.values(filterCommentsDepOnList),
(uri, maxCount = -1, byClaimId, byUri, ...filterInputs) => { (uri, maxCount = -1, byClaimId, claimId, ...filterInputs) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId]; const comments = byClaimId && byClaimId[claimId];
const filtered = filterComments(comments, claimId, filterInputs); const filtered = filterComments(comments, claimId, filterInputs);
return maxCount > 0 ? filtered.slice(0, maxCount) : filtered; return maxCount > 0 ? filtered.slice(0, maxCount) : filtered;
} }
)((state, uri, maxCount = -1) => `${String(uri)}:${maxCount}`); )((state, uri, maxCount = -1) => `${String(uri)}:${maxCount}`);
export const makeSelectTopLevelTotalCommentsForUri = (uri: string) =>
createSelector(selectState, selectCommentsByUri, (state, byUri) => {
const claimId = byUri[uri];
return state.topLevelTotalCommentsById[claimId] || 0;
});
export const makeSelectTopLevelTotalPagesForUri = (uri: string) => export const makeSelectTopLevelTotalPagesForUri = (uri: string) =>
createSelector(selectState, selectCommentsByUri, (state, byUri) => { createSelector(selectState, selectCommentsByUri, (state, byUri) => {
const claimId = byUri[uri]; const claimId = byUri[uri];