/** @jsx h */ import { h, Component } from 'preact'; import { connect } from 'preact-redux'; import Comment from 'components/comment'; import { setCollapse } from './thread.actions'; import { getThreadIsCollapsed } from './thread.getters'; class Thread extends Component { constructor(props) { super(props); this.onCollapseToggle = this.onCollapseToggle.bind(this); } onCollapseToggle() { this.props.setCollapse(this.props.data.comment, !this.props.collapsed); } render(props) { const { collapsed, data: { comment, replies = [] }, mods = {}, isCommentsDisabled, } = props; return (
{!collapsed && !!replies.length && replies.map(thread => ( ))}
); } } const ConnectedThread = connect( (state, props) => ({ collapsed: getThreadIsCollapsed(state, props.data.comment) }), { setCollapse } )(Thread); export default ConnectedThread;