2015-11-22 00:10:46 +01:00
|
|
|
var React = require('react')
|
2015-11-23 16:07:04 +01:00
|
|
|
var Link = require('react-router').Link
|
2015-11-28 10:18:06 +01:00
|
|
|
var UserID = require('userID.jsx')
|
|
|
|
var GetIPFS = require('getipfs.jsx')
|
|
|
|
var Post = require('post.jsx')
|
2015-11-22 00:10:46 +01:00
|
|
|
|
2015-12-14 00:29:25 +01:00
|
|
|
module.exports = function (boardsAPI) {
|
2015-11-22 00:10:46 +01:00
|
|
|
return React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
getInitialState: function () {
|
2015-12-17 22:19:21 +01:00
|
|
|
return { }
|
2015-11-22 00:10:46 +01:00
|
|
|
},
|
2015-12-14 00:29:25 +01:00
|
|
|
componentDidMount: function () {
|
2015-11-23 13:00:49 +01:00
|
|
|
boardsAPI.use(boards => {
|
2015-12-23 11:47:31 +01:00
|
|
|
this.setState({ api: boards, allowReply: boards.isInit && !boards.limited })
|
|
|
|
boards.getEventEmitter().on('init', (err, limited) => {
|
|
|
|
this.setState({ api: boards, allowReply: !err && !limited })
|
|
|
|
})
|
2015-11-22 00:10:46 +01:00
|
|
|
})
|
|
|
|
},
|
2015-12-14 00:29:25 +01:00
|
|
|
getContext: function () {
|
|
|
|
if (this.props.params.userid) {
|
|
|
|
if (this.props.params.boardname) {
|
2015-12-18 22:22:26 +01:00
|
|
|
return <div>Posted by <UserID id={this.props.params.userid} api={this.state.api} /> in <Link to={'@' + this.props.params.userid + '/' + this.props.params.boardname}>#{this.props.params.boardname}</Link></div>
|
2015-12-14 00:29:25 +01:00
|
|
|
} else {
|
2015-12-18 22:22:26 +01:00
|
|
|
return <div>Posted by <UserID id={this.props.params.userid} api={this.state.api} /></div>
|
2015-12-14 00:29:25 +01:00
|
|
|
}
|
2016-06-20 18:07:11 +02:00
|
|
|
} else return <div><h6 className='light'>You are viewing a single post</h6></div>
|
2015-11-23 16:07:04 +01:00
|
|
|
},
|
2015-12-14 00:29:25 +01:00
|
|
|
render: function () {
|
|
|
|
if (this.state.api) {
|
2016-06-20 18:07:11 +02:00
|
|
|
return <div className='post-page'>
|
|
|
|
<div className='text-center'>
|
2015-11-23 16:07:04 +01:00
|
|
|
{this.getContext()}
|
|
|
|
</div>
|
2015-12-23 11:47:31 +01:00
|
|
|
<Post allowReply={true} hash={this.props.params.posthash} board={this.props.params.boardname} api={this.state.api} adminID={this.props.params.userid} />
|
2015-11-23 16:07:04 +01:00
|
|
|
</div>
|
2015-12-14 00:29:25 +01:00
|
|
|
} else {
|
|
|
|
return <GetIPFS api={this.state.boards} />
|
|
|
|
}
|
2015-11-22 00:10:46 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|