React = require 'react' {Actions} = require("inbox-exports") SidebarDividerItem = require("./account-sidebar-divider-item.cjsx") SidebarTagItem = require("./account-sidebar-tag-item.cjsx") SidebarStore = require ("./account-sidebar-store") module.exports = AccountSidebar = React.createClass displayName: 'AccountSidebar' getInitialState: -> @_getStateFromStores() componentDidMount: -> @unsubscribe = SidebarStore.listen @_onStoreChange # It's important that every React class explicitly stops listening to # atom events before it unmounts. Thank you event-kit # This can be fixed via a Reflux mixin componentWillUnmount: -> @unsubscribe() if @unsubscribe render: ->
{@_sections()}
_sections: -> return @state.sections.map (section) =>
{@_itemComponents(section)}
_itemComponents: (section) -> return section.tags?.map (tag) => _onStoreChange: -> @setState @_getStateFromStores() if not SidebarStore.selectedId()? Actions.selectTagId("inbox") _getStateFromStores: -> sections: SidebarStore.sections() selected: SidebarStore.selectedId() AccountSidebar.minWidth = 165 AccountSidebar.maxWidth = 250