File size: 680 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 ?? {};
};