File size: 756 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import treeSelect from '@automattic/tree-select';
import { findLast } from 'lodash';
import { getPostCommentItems } from 'calypso/state/comments/selectors/get-post-comment-items';
import 'calypso/state/comments/init';
/**
* Get oldest comment date for a given post
* @param {Object} state redux state
* @param {number} siteId site identification
* @param {number} postId site identification
* @returns {Date} earliest comment date
*/
export const getPostOldestCommentDate = treeSelect(
( state, siteId, postId ) => [ getPostCommentItems( state, siteId, postId ) ],
( [ comments ] ) => {
const lastContiguousComment = findLast( comments, 'contiguous' );
return lastContiguousComment ? new Date( lastContiguousComment.date ) : undefined;
}
);
|