File size: 913 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';
import { requestComment } from 'calypso/state/comments/actions';

export class QueryComment extends Component {
	static propTypes = {
		commentId: PropTypes.number,
		forceWpcom: PropTypes.bool,
		siteId: PropTypes.number,
	};

	static defaultProps = {
		forceWpcom: false,
	};

	componentDidMount() {
		this.request();
	}

	componentDidUpdate( { siteId, commentId } ) {
		if ( siteId !== this.props.siteId || commentId !== this.props.commentId ) {
			this.request();
		}
	}

	request() {
		const { siteId, commentId, forceWpcom } = this.props;
		if ( siteId && commentId ) {
			const query = forceWpcom ? { force: 'wpcom' } : {};

			this.props.requestComment( { siteId, commentId, query } );
		}
	}

	render() {
		return null;
	}
}

export default connect( null, { requestComment } )( QueryComment );