/** @jsx h */ import { h, RenderableProps } from 'preact'; import { connect } from 'preact-redux'; import b from 'bem-react-helper'; import { ConnectedComment as Comment } from '@app/components/comment/connected-comment'; import { Node } from '@app/common/types'; import { getThreadIsCollapsed } from '@app/store/thread/getters'; import { StoreState } from '@app/store'; interface Props { collapsed: boolean; data: Node; isCommentsDisabled: boolean; level: number; mix?: string; getPreview(text: string): Promise; } function Thread(props: RenderableProps) { const { collapsed, data: { comment, replies = [] }, level, } = props; return (
{!collapsed && !!replies.length && replies.map(thread => ( ))}
); } export const ConnectedThread = connect((state: StoreState, props: { data: Node }) => ({ collapsed: getThreadIsCollapsed(state, props.data.comment), isCommentsDisabled: !!state.info.read_only, }))(Thread);