var React = require('react') var Markdown = require('markdown.jsx') var Icon = require('icon.jsx') var Link = require('react-router').Link var Clock = require('clock.jsx') var UserID = require('userID.jsx') var { Error } = require('status-components.jsx') var { Comments, CommentEditor } = require('comment.jsx') module.exports = React.createClass({ getInitialState () { return { loading: true } }, componentDidMount () { if (this.props.api) { this.props.api.getEventEmitter().on('init', (err, limited) => { if (!err || limited) this.init(this.props) }) if (this.props.api.isInit || this.props.api.limited) this.init(this.props) } }, componentWillReceiveProps (props) { this.init(props) }, init (props) { var boards = props.api if (!boards) return this.setState({ error: 'Could not connect to IPFS' }) this.setState({ loading: true, userid: boards.getMyID() }) boards.downloadPost(props.hash, props.adminID, props.board, (err, hash, date, post) => { this.setState({ error: err, post: post, loading: false }) }) }, postLink () { if (this.state.post.op) { if (this.props.board) { return '/@' + this.state.post.op + '/' + this.props.board + '/' + this.props.hash } else { return '/@' + this.state.post.op + '/post/' + this.props.hash } } else { return '/post/' + this.props.hash } }, editorLink () { if (this.state.post.op === this.state.userid) { var board = this.props.board || this.state.post.board if (board) { var url = '/edit/board/' + board + '/post/' + this.props.hash return Edit } else { return } } else return }, toggleReply () { this.setState({ reply: !this.state.reply }) }, getContent () { if (this.state.error) { return } else if (this.state.loading) { return
Downloading Post
} else { return
{ this.state.post.title ?
{this.state.post.title}

:
}
View { this.props.allowReply ? Reply : } {this.editorLink()}
} }, render () { return
{this.getContent()}
{ this.state.reply ? :
}
} })