File size: 854 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 };
	}
);