react-code-dataset / wp-calypso /client /state /comments /selectors /get-hidden-comments-for-post.js
react-code-dataset / wp-calypso /client /state /comments /selectors /get-hidden-comments-for-post.js
Download wp-calypso/client/state/comments/selectors/get-hidden-comments-for-post.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-hidden-comments-for-post.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/selectors/get-hidden-comments-for-post.js
-
curl -L -o get-hidden-comments-for-post.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-hidden-comments-for-post.js
671 Bytes
| import treeSelect from '@automattic/tree-select'; | |
| import { keyBy, pickBy } from 'lodash'; | |
| import { getExpansionsForPost } from 'calypso/state/comments/selectors/get-expansions-for-post'; | |
| import { getPostCommentItems } from 'calypso/state/comments/selectors/get-post-comment-items'; | |
| import 'calypso/state/comments/init'; | |
| export const getHiddenCommentsForPost = treeSelect( | |
| ( state, siteId, postId ) => [ | |
| getPostCommentItems( state, siteId, postId ), | |
| getExpansionsForPost( state, siteId, postId ), | |
| ], | |
| ( [ comments, expanded ] ) => { | |
| const commentsById = keyBy( comments, 'ID' ); | |
| return pickBy( commentsById, ( comment ) => ! expanded?.[ comment.ID ] ); | |
| } | |
| ); | |