Download wp-calypso/client/state/comments/selectors/get-comment-like.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-comment-like.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/selectors/get-comment-like.js
-
curl -L -o get-comment-like.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-comment-like.js
854 Bytes
| import treeSelect from '@automattic/tree-select'; | |
| import { find } from 'lodash'; | |
| import { getPostCommentItems } from 'calypso/state/comments/selectors/get-post-comment-items'; | |
| import 'calypso/state/comments/init'; | |
| /** | |
| * Gets likes stats for the comment | |
| * @param {Object} state redux state | |
| * @param {number} siteId site identification | |
| * @param {number} postId site identification | |
| * @param {number} commentId comment identification | |
| * @returns {Object} that has i_like and like_count props | |
| */ | |
| export const getCommentLike = treeSelect( | |
| ( state, siteId, postId ) => [ getPostCommentItems( state, siteId, postId ) ], | |
| ( [ comments ], siteId, postId, commentId ) => { | |
| const comment = find( comments, { ID: commentId } ); | |
| if ( ! comment ) { | |
| return undefined; | |
| } | |
| const { i_like, like_count } = comment; | |
| return { i_like, like_count }; | |
| } | |
| ); | |