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