import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { setupListAdder, resetListAdder } from '../../actions/lists'; import { createSelector } from 'reselect'; import List from './components/list'; import Account from './components/account'; import IconButton from 'gabsocial/components/icon_button'; import NewListForm from '../lists/components/new_list_form'; import ColumnSubheading from '../ui/components/column_subheading'; // hack const getOrderedLists = createSelector([state => state.get('lists')], lists => { if (!lists) { return lists; } return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title'))); }); const mapStateToProps = (state, {accountId}) => ({ listIds: getOrderedLists(state).map(list=>list.get('id')), account: state.getIn(['accounts', accountId]), }); const mapDispatchToProps = dispatch => ({ onInitialize: accountId => dispatch(setupListAdder(accountId)), onReset: () => dispatch(resetListAdder()), }); const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, subheading: { id: 'lists.subheading', defaultMessage: 'Your lists' }, add: { id: 'lists.new.create', defaultMessage: 'Add List' }, }); export default @connect(mapStateToProps, mapDispatchToProps) @injectIntl class ListAdder extends ImmutablePureComponent { static propTypes = { accountId: PropTypes.string.isRequired, onClose: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, onInitialize: PropTypes.func.isRequired, onReset: PropTypes.func.isRequired, listIds: ImmutablePropTypes.list.isRequired, account: ImmutablePropTypes.map, }; componentDidMount () { const { onInitialize, accountId } = this.props; onInitialize(accountId); } componentWillUnmount () { const { onReset } = this.props; onReset(); } onClickClose = () => { this.props.onClose('LIST_ADDER'); }; render () { const { accountId, listIds, intl, onClose, account } = this.props; const displayNameHtml = account ? { __html: account.get('display_name_html') } : ''; return (



{listIds.map(ListId => )}
); } }