<commit_before>import {createSelector} from 'reselect';

const emptyArray = [];

const makeGetPostComments = () => createSelector(
  [
    (state, props) => state.posts[props.postId],
    (state, props) => state.postViews[props.postId],
    (state) => state.user.id
  ],
  (post, postView, myId) => {
    const postCombined = {
      comments: emptyArray,
      ...post,
      ...postView,
      isEditable: (post.createdBy === myId)
    };

    return {
      post: postCombined
    };
  }
);

export default makeGetPostComments;<commit_msg>[components-rewiring] PostComments: make selector super-granular<commit_after>import {createSelector} from 'reselect';

const emptyArray = [];

const makeGetPostComments = () => createSelector(
  [
    (state, props) => state.posts[props.postId].id,
    (state, props) => state.posts[props.postId].comments || emptyArray,
    (state, props) => state.posts[props.postId].omittedComments || 0,
    (state, props) => state.posts[props.postId].commentsDisabled,

    (state, props) => state.postViews[props.postId].isLoadingComments,
    (state, props) => state.postViews[props.postId].isModeratingComments,
    (state, props) => state.postViews[props.postId].isCommenting,
    (state, props) => state.postViews[props.postId].isSavingComment,
    (state, props) => state.postViews[props.postId].commentError,

    (state, props) => (state.posts[props.postId].createdBy === state.user.id)
  ],
  (
    id, comments, omittedComments, commentsDisabled,
    isLoadingComments, isModeratingComments, isCommenting, isSavingComment, commentError,
    isEditable
  ) => {
    const granularPostData = {
      id,
      comments,
      omittedComments,
      commentsDisabled,

      isLoadingComments,
      isModeratingComments,
      isCommenting,
      isSavingComment,
      commentError,

      isEditable
    };

    return {
      post: granularPostData
    };
  }
);

export default makeGetPostComments;
{'fraction_non_alphanumeric': 0.13601236476043277, 'fraction_numerical': 0.0005151983513652757, 'mean_word_length': 3.5373831775700935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112743', 'n_tokens_mistral': 626, 'n_tokens_neox': 598, 'n_words': 108}