Fix comment count not incremented it was previously 0 #1067
This commit is contained in:
commit
f3f1c1ad5e
5 changed files with 21 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { selectClaimForUri,
|
||||
import {
|
||||
selectClaimForUri,
|
||||
selectClaimIsMine,
|
||||
selectFetchingMyChannels,
|
||||
selectClaimsByUri,
|
||||
|
@ -10,7 +11,7 @@ import {
|
|||
selectIsFetchingComments,
|
||||
selectIsFetchingCommentsById,
|
||||
selectIsFetchingReacts,
|
||||
makeSelectTotalCommentsCountForUri,
|
||||
selectTotalCommentsCountForUri,
|
||||
selectOthersReacts,
|
||||
selectMyReacts,
|
||||
selectCommentIdsForUri,
|
||||
|
@ -34,7 +35,7 @@ const select = (state, props) => {
|
|||
allCommentIds: selectCommentIdsForUri(state, uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(uri)(state),
|
||||
totalComments: selectTotalCommentsCountForUri(state, uri),
|
||||
claimId: claim && claim.claim_id,
|
||||
channelId: getChannelIdFromClaim(claim),
|
||||
claimIsMine: selectClaimIsMine(state, claim),
|
||||
|
|
|
@ -14,7 +14,7 @@ import * as SETTINGS from 'constants/settings';
|
|||
import { selectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
|
||||
import { selectShowMatureContent, selectClientSetting } from 'redux/selectors/settings';
|
||||
import { makeSelectFileRenderModeForUri, makeSelectContentPositionForUri } from 'redux/selectors/content';
|
||||
import { makeSelectCommentsListTitleForUri, selectSettingsByChannelId } from 'redux/selectors/comments';
|
||||
import { selectCommentsListTitleForUri, selectSettingsByChannelId } from 'redux/selectors/comments';
|
||||
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
|
||||
|
@ -43,7 +43,7 @@ const select = (state, props) => {
|
|||
hasCollectionById: Boolean(makeSelectCollectionForId(collectionId)(state)),
|
||||
collectionId,
|
||||
position: makeSelectContentPositionForUri(uri)(state),
|
||||
commentsListTitle: makeSelectCommentsListTitleForUri(uri)(state),
|
||||
commentsListTitle: selectCommentsListTitleForUri(state, uri),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { selectActiveChannelClaim } from 'redux/selectors/app';
|
|||
import {
|
||||
selectIsFetchingComments,
|
||||
selectCommentsForUri,
|
||||
makeSelectTotalCommentsCountForUri,
|
||||
selectTotalCommentsCountForUri,
|
||||
makeSelectTopLevelTotalPagesForUri,
|
||||
} from 'redux/selectors/comments';
|
||||
import { selectClaimsById } from 'redux/selectors/claims';
|
||||
|
@ -18,7 +18,7 @@ const select = (state) => {
|
|||
return {
|
||||
activeChannelClaim,
|
||||
allComments: selectCommentsForUri(state, uri),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(uri)(state),
|
||||
totalComments: selectTotalCommentsCountForUri(state, uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(uri)(state),
|
||||
isFetchingComments: selectIsFetchingComments(state),
|
||||
claimsById: selectClaimsById(state),
|
||||
|
|
|
@ -120,7 +120,7 @@ export default handleActions(
|
|||
newCommentIds.unshift(comment.comment_id);
|
||||
byId[claimId] = newCommentIds;
|
||||
|
||||
if (totalCommentsById[claimId]) {
|
||||
if (totalCommentsById.hasOwnProperty(claimId)) {
|
||||
totalCommentsById[claimId] += 1;
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ export default handleActions(
|
|||
}
|
||||
}
|
||||
|
||||
if (totalCommentsById[claimId]) {
|
||||
if (totalCommentsById.hasOwnProperty(claimId)) {
|
||||
totalCommentsById[claimId] = Math.max(0, totalCommentsById[claimId] - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ export const selectCommentsById = (state: State) => selectState(state).commentBy
|
|||
export const selectCommentIdsByClaimId = (state: State) => selectState(state).byId;
|
||||
export const selectIsFetchingComments = (state: State) => selectState(state).isLoading;
|
||||
export const selectIsFetchingCommentsById = (state: State) => selectState(state).isLoadingById;
|
||||
const selectTotalCommentsById = (state: State) => selectState(state).totalCommentsById;
|
||||
export const selectIsFetchingReacts = (state: State) => selectState(state).isFetchingReacts;
|
||||
|
||||
export const selectMyReacts = (state: State) => state.comments.myReactsByCommentId;
|
||||
|
@ -338,17 +339,17 @@ export const makeSelectTotalReplyPagesForParentId = (parentId: string) =>
|
|||
return state.repliesTotalPagesByParentId[parentId] || 0;
|
||||
});
|
||||
|
||||
export const makeSelectTotalCommentsCountForUri = (uri: string) =>
|
||||
createSelector(selectState, selectCommentsByUri, (state, byUri) => {
|
||||
const claimId = byUri[uri];
|
||||
export const selectTotalCommentsCountForUri = (state: State, uri: string) => {
|
||||
const commentIdsByUri = selectCommentsByUri(state);
|
||||
const totalCommentsById = selectTotalCommentsById(state);
|
||||
const claimId = commentIdsByUri[uri];
|
||||
return totalCommentsById[claimId] || 0;
|
||||
};
|
||||
|
||||
return state.totalCommentsById[claimId] || 0;
|
||||
});
|
||||
|
||||
export const makeSelectCommentsListTitleForUri = (uri: string) =>
|
||||
createSelector(makeSelectTotalCommentsCountForUri(uri), (totalComments) => {
|
||||
return getCommentsListTitle(totalComments);
|
||||
});
|
||||
export const selectCommentsListTitleForUri = (state: State, uri: string) => {
|
||||
const totalComments = selectTotalCommentsCountForUri(state, uri);
|
||||
return getCommentsListTitle(totalComments);
|
||||
};
|
||||
|
||||
// Personal list
|
||||
export const makeSelectChannelIsBlocked = (uri: string) =>
|
||||
|
|
Loading…
Reference in a new issue