var React = require('react') var Markdown = require('markdown.jsx') var Link = require('react-router').Link var Icon = require('icon.jsx') var GetIPFS = require('getipfs.jsx') var { Loading, Error } = require('status-components.jsx') module.exports = function (boardsAPI) { return React.createClass({ getInitialState () { return { loading: true, boards: [], api: false } }, componentDidMount () { boardsAPI.use(boards => { if (boards.isInit || boards.limited) { this.init(boards) } var ee = boards.getEventEmitter() ee.on('init', (err, limited) => { if ((!err || limited) && this.isMounted()) { this.init(boards) } }) }) }, componentWillReceiveProps (nextProps) { boardsAPI.use(boards => this.downloadProfile(boards, nextProps)) this.setState({ loading: true }) }, downloadProfile (boards, props) { var ee = boards.getEventEmitter() var uid = props.params.userid ee.on('boards for ' + uid, l => { var u2id = props.params.userid if (!this.isMounted() || u2id !== uid) return true this.setState({ boards: l }) }) boards.getProfile(uid, (err, res) => { if (!this.isMounted()) return true if (err) { this.setState({ loading: false, error: err }) } else { this.setState({ loading: false, name: res.name, description: res.description }) } }) }, init (boards) { if (this.state.init) return this.setState({ init: true, api: boards, id: boards.id, limited: boards.limited }) this.downloadProfile(boards, this.props) }, linkToEditor () { var uid = this.props.params.userid if (uid === this.state.id) { return