diff --git a/webapp/pages/users.jsx b/webapp/pages/users.jsx index bb24ac1..804659e 100644 --- a/webapp/pages/users.jsx +++ b/webapp/pages/users.jsx @@ -5,24 +5,13 @@ var UserID = require('userID.jsx') module.exports = function (boardsAPI) { return React.createClass({ - getInitialState: function () { + getInitialState () { return { users: [], api: false } }, - componentDidMount: function () { + componentDidMount () { boardsAPI.use(boards => { - boards.init() - if (boards.isInit) { - if (this.isMounted()) { - this.init(boards) - } - } - var ee = boards.getEventEmitter() - ee.on('init', e => { - if (!e && this.isMounted()) { - this.init(boards) - } - }) - ee.on('user', (id) => { + this.init(boards) + boards.getEventEmitter().on('user', (id) => { if (id === undefined || id === 'undefined') console.log('found undefined user???') if (this.isMounted() && this.state.users.indexOf(id) < 0) { this.setState({ users: this.state.users.concat(id) }) @@ -30,24 +19,22 @@ module.exports = function (boardsAPI) { }) }) }, - init: function (boards) { - if (this.isMounted() && !this.state.init) { - this.setState({ users: boards.getUsers(), api: true, init: true, boards: boards }) - boards.searchUsers() - } + init (boards) { + this.setState({ users: boards.getUsers(), api: boards }) + boards.searchUsers() }, - render: function () { + render () { if (this.state.api) { return
-

Users

+

Users

Found {this.state.users.length} users

- } else return + } else return } }) }