"use strict"; var App = React.createClass({ getDefaultProps() { return { gather: { gatherers: [] }, users: [], messages: [], maps: [], servers: [], archive: [], soundController: null } }, thisGatherer() { let gather = this.props.gather; let user = this.props.user; if (gather && user && gather.gatherers.length) { return gather.gatherers .filter(gatherer => gatherer.id === user.id) .pop() || null; } return null; }, componentDidMount() { let self = this; let socket = this.props.socket; let soundController = this.props.soundController; socket.on('notification', data => { if (data && data.sound === 'gather_starting' && this.thisGatherer()) { soundController.playGatherMusic(); } }); socket.on('users:update', data => self.setProps({ users: data.users, user: data.currentUser }) ); socket.on("message:append", data => { self.setProps({ messages: self.props.messages.concat(data.messages) .sort((a, b) => { return new Date(a.createdAt) - new Date(b.createdAt); }) }); }); socket.on("message:refresh", data => { self.setProps({ messages: data.messages }); }); socket.on("gather:refresh", (data) => { self.setProps({ gather: data.gather, maps: data.maps, servers: data.servers, previousGather: data.previousGather }); }); socket.on("gather:archive:refresh", data => { self.setProps({ archive: data.archive, maps: data.maps, servers: data.servers }); }); socket.emit("users:refresh"); socket.emit("message:refresh"); }, render() { return