var React = require('react') var GetIPFS = require('getipfs.jsx') var Icon = require('icon.jsx') var Link = require('react-router').Link module.exports = function (boardsAPI) { return React.createClass({ getInitialState () { return { loading: true } }, componentDidMount () { 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) } }) }, getProfile (boards) { boards.getProfile(boards.getMyID(), (err, p) => { if (!this.isMounted()) return else if (err) this.setState({ loading: false }) else if (this.state.loading) { // State isn't set to p directly to avoid XSS. // There is no knowing what's gonna be in a profile // Should also convert to string and check length etc. this.setState({ name: p.name, description: p.description, loading: false }) } }) }, init (boards) { if (this.state.init) return this.setState({ api: boards }) this.getProfile(boards) }, handleChange (event) { if (event.target.id === 'name') { this.setState({ name: event.target.value }) } else { this.setState({ description: event.target.value }) } }, skip () { this.setState({ loading: false, updating: false, error: false }) }, refresh () { this.setState({ loading: true }) boardsAPI.use(b => this.getProfile(b)) }, save () { var boards = this.state.api var profile = { name: this.state.name, description: this.state.description } this.setState({ updating: true }) boards.createProfile(profile, err => { this.setState({ error: err, updating: false }) if (err) console.log('Profile Publish error:', err) }) }, render () { if (this.state.api) { if (this.state.error) { return
{'' + this.state.error}
Pressing the Skip button will not abort the publish operation.
This App uses IPFS to store your profile. When you are offline, other users or servers that viewed your profile will serve it to others.
Warning: due to a bug in go-ipfs, it may take up to a minute for your changes to be visibile. Your profile will appear unchanged during this time.