var React = require('react') var Link = require('react-router').Link var UserID = require('userID.jsx') var GetIPFS = require('getipfs.jsx') var Post = require('post.jsx') var Comments = require('comment.jsx').Comments module.exports = function (boardsAPI) { return React.createClass({ getInitialState: function () { return { post: { title: '...', text: '...' }, api: false } }, componentDidMount: function () { boardsAPI.use(boards => { boards.init() boards.getEventEmitter().on('init', err => { if (!err && this.isMounted()) { this.init(boards) } }) if (this.isMounted() && boards.isInit) { this.init(boards) } }) }, componentWillReceiveProps: function (nextProps) { boardsAPI.use(boards => this.downloadPost(boards, nextProps)) }, downloadPost: function (boards, props) { boards.downloadPost(props.params.posthash, props.params.userid, props.params.boardname, props.params.userid, (err, post) => { if (err) { this.setState({ post: { title: 'Error', text: err.Message || err.Error } }) } else { this.setState({ post }) } }) }, init: function (boards) { if (this.state.init) return this.setState({ api: true, boards: boards }) this.downloadPost(boards, this.props) }, getContext: function () { if (this.props.params.userid) { if (this.props.params.boardname) { return
Posted by in #{this.props.params.boardname}
} else { return
Posted by
} } else return
You are viewing a single post
}, render: function () { if (this.state.api) { return
{this.getContext()}
} else { return } } }) }