Download wp-calypso/client/state/comments/selectors/get-parent-comment.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 680 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-parent-comment.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/selectors/get-parent-comment.js
-
curl -L -o get-parent-comment.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-parent-comment.js
680 Bytes
| import { getPostCommentsTree } from 'calypso/state/comments/selectors/get-post-comments-tree'; | |
| import 'calypso/state/comments/init'; | |
| /** | |
| * Returns the parent comment of a given comment | |
| * @param {Object} state Redux state | |
| * @param {number} siteId Site identifier | |
| * @param {number} postId Post identifier | |
| * @param {number} commentId Comment identifier | |
| * @returns {Object} The parent comment | |
| */ | |
| export const getParentComment = ( state, siteId, postId, commentId ) => { | |
| const commentsTree = getPostCommentsTree( state, siteId, postId, 'all' ); | |
| const parentCommentId = commentsTree[ commentId ]?.data.parent?.ID ?? 0; | |
| return commentsTree[ parentCommentId ]?.data ?? {}; | |
| }; | |