react-code-dataset / wp-calypso /client /state /comments /selectors /get-post-newest-comment-date.js
react-code-dataset / wp-calypso /client /state /comments /selectors /get-post-newest-comment-date.js
Download wp-calypso/client/state/comments/selectors/get-post-newest-comment-date.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-post-newest-comment-date.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/selectors/get-post-newest-comment-date.js
-
curl -L -o get-post-newest-comment-date.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/get-post-newest-comment-date.js
759 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'; | |
| /** | |
| * Get most recent comment date for a given post | |
| * @param {Object} state redux state | |
| * @param {number} siteId site identification | |
| * @param {number} postId site identification | |
| * @returns {Date} most recent comment date | |
| */ | |
| export const getPostNewestCommentDate = treeSelect( | |
| ( state, siteId, postId ) => [ getPostCommentItems( state, siteId, postId ) ], | |
| ( [ comments ] ) => { | |
| const firstContiguousComment = find( comments, 'contiguous' ); | |
| return firstContiguousComment ? new Date( firstContiguousComment.date ) : undefined; | |
| } | |
| ); | |