_ = require 'underscore' path = require 'path' React = require 'react' {RetinaImg} = require 'nylas-component-kit' {Actions, Event, Utils, ComponentRegistry, AccountStore} = require 'nylas-exports' EventRSVPTask = require './tasks/event-rsvp' moment = require 'moment-timezone' class EventComponent extends React.Component @displayName: 'EventComponent' @propTypes: event: React.PropTypes.object.isRequired constructor: (@props) -> # Since getting state is asynchronous, default to empty values @state = @_nullEvent() _nullEvent: -> participants: [] title: "" when: {start_time: 0} _onChange: => DatabaseStore.find(Event, @props.event.id).then (event) => event ?= @_nullEvent() @setState(event) componentDidMount: -> @_onChange() componentWillMount: -> @usubs.push DatabaseStore.listen (change) => @_onChange() if change.objectClass is Event.name @usubs.push AccountStore.listen(@_onChange) componentWillUnmount: -> usub?() for usub in @usubs() _myStatus: => myEmail = AccountStore.current()?.me().email for p in @state.participants if p['email'] == myEmail return p['status'] return null render: =>