File size: 495 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import 'calypso/state/comments/init';

/**
 * Return comment counts for the given site and post ID, if applicable.
 * @param {Object} state Redux state
 * @param {number} siteId Site identifier
 * @param {number} [postId] Post identifier
 * @returns {Object} The requested comment counts
 */
export function getSiteCommentCounts( state, siteId, postId ) {
	if ( postId ) {
		return state.comments.counts[ siteId ]?.[ postId ] ?? null;
	}
	return state.comments.counts[ siteId ]?.site ?? null;
}