import * as React from "react" ; import { Map } from "immutable" ; import { connect , DispatchProp } from "react-redux" ; import { addRevision } from "./actions" ; import { EthContentHeader } from "@joincivil/typescript-types" ; import { ContentViewerReduxState , RevisionAndJson } from "./reducers" ; import { ContentItem } from "./ContentItem" ; import { Newsroom } from "@joincivil/core/build/src/contracts/newsroom" ; export interface ContentViewerProps { newsroom : Newsroom ; } export interface ContentInternalViewerProps extends ContentViewerProps { content : Map < number , Map < number , RevisionAndJson > > ; } class ContentViewerComponent extends React . Component < ContentInternalViewerProps & DispatchProp < any > > { public componentDidMount ( ) { this . props . newsroom . revisions ( ) . subscribe ( ( item ) => { this . props . dispatch ! ( addRevision ( item ) ) ; } ) ; } public render ( ) { const content = this . props . content . toArray ( ) ; return ( < div > < h2 > Content < /h2> { content . map ( ( item , index ) : JSX . Element => ( < ContentItem key = { index } content = { item } / > ) ) } < /div>); } } const mapStateToProps = ( state , ownProps ) : ContentInternalViewerProps => { return { content : state . newsroomContent , ... ownProps , } ; } ; export const ContentViewer = connect ( mapStateToProps ) ( ContentViewerComponent ) ;