var React = require('react') var GetIPFS = require('getipfs.jsx') var Icon = require('icon.jsx') 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 }) }, save () { var boards = this.state.api var profile = { name: this.state.name, description: this.state.description } boards.createProfile(profile, err => { console.log('CREATE:', err) }) }, render () { if (this.state.api) { if (this.state.loading) { return

Fetching your current profile...

} else { return (

Edit Profile

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.