var React = require('react') var Link = require('react-router').Link var Icon = require('icon.jsx') var UserID = require('userID.jsx') var GetIPFS = require('getipfs.jsx') var Post = require('post.jsx') var Comment = require('comment.jsx').Comment module.exports = function(boardsAPI){ return React.createClass({ getInitialState: function(){ return { parent: false, 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.downloadComment(boards,nextProps)) }, downloadComment: function(boards,props){ this.setState({ comment: false }) boards.downloadComment(props.params.commenthash,props.params.userid,props.params.boardname,(err,comment) => { if(err){ this.setState({ comment: { title: 'Error', text: err.Message || err.Error }}) } else { this.setState({ comment }) } }) }, init: function(boards){ if(this.state.init) return this.setState({ api: true, boards: boards }) this.downloadComment(boards,this.props) }, getContext: function(){ if(this.props.params.userid){ if(this.props.params.boardname) return