You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.5 KiB
80 lines
2.5 KiB
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import { connect } from 'react-redux';
|
||
6 years ago
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||
6 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
6 years ago
|
import { debounce } from 'lodash';
|
||
8 years ago
|
import PropTypes from 'prop-types';
|
||
8 years ago
|
import LoadingIndicator from '../../components/loading_indicator';
|
||
|
import Column from '../ui/components/column';
|
||
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
||
|
import AccountContainer from '../../containers/account_container';
|
||
|
import { fetchBlocks, expandBlocks } from '../../actions/blocks';
|
||
6 years ago
|
import ScrollableList from '../../components/scrollable_list';
|
||
8 years ago
|
|
||
|
const messages = defineMessages({
|
||
8 years ago
|
heading: { id: 'column.blocks', defaultMessage: 'Blocked users' },
|
||
8 years ago
|
});
|
||
|
|
||
|
const mapStateToProps = state => ({
|
||
8 years ago
|
accountIds: state.getIn(['user_lists', 'blocks', 'items']),
|
||
6 years ago
|
hasMore: !!state.getIn(['user_lists', 'blocks', 'next']),
|
||
5 years ago
|
isLoading: state.getIn(['user_lists', 'blocks', 'isLoading'], true),
|
||
8 years ago
|
});
|
||
|
|
||
6 years ago
|
export default @connect(mapStateToProps)
|
||
8 years ago
|
@injectIntl
|
||
6 years ago
|
class Blocks extends ImmutablePureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static propTypes = {
|
||
|
params: PropTypes.object.isRequired,
|
||
|
dispatch: PropTypes.func.isRequired,
|
||
|
accountIds: ImmutablePropTypes.list,
|
||
6 years ago
|
hasMore: PropTypes.bool,
|
||
5 years ago
|
isLoading: PropTypes.bool,
|
||
8 years ago
|
intl: PropTypes.object.isRequired,
|
||
5 years ago
|
multiColumn: PropTypes.bool,
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
componentWillMount () {
|
||
|
this.props.dispatch(fetchBlocks());
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
6 years ago
|
handleLoadMore = debounce(() => {
|
||
|
this.props.dispatch(expandBlocks());
|
||
|
}, 300, { leading: true });
|
||
8 years ago
|
|
||
|
render () {
|
||
3 years ago
|
const { intl, accountIds, hasMore, multiColumn, isLoading } = this.props;
|
||
8 years ago
|
|
||
|
if (!accountIds) {
|
||
|
return (
|
||
|
<Column>
|
||
|
<LoadingIndicator />
|
||
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
6 years ago
|
const emptyMessage = <FormattedMessage id='empty_column.blocks' defaultMessage="You haven't blocked any users yet." />;
|
||
|
|
||
8 years ago
|
return (
|
||
5 years ago
|
<Column bindToDocument={!multiColumn} icon='ban' heading={intl.formatMessage(messages.heading)}>
|
||
8 years ago
|
<ColumnBackButtonSlim />
|
||
6 years ago
|
<ScrollableList
|
||
|
scrollKey='blocks'
|
||
|
onLoadMore={this.handleLoadMore}
|
||
6 years ago
|
hasMore={hasMore}
|
||
5 years ago
|
isLoading={isLoading}
|
||
6 years ago
|
emptyMessage={emptyMessage}
|
||
5 years ago
|
bindToDocument={!multiColumn}
|
||
6 years ago
|
>
|
||
|
{accountIds.map(id =>
|
||
3 years ago
|
<AccountContainer key={id} id={id} defaultAction='block' />,
|
||
6 years ago
|
)}
|
||
|
</ScrollableList>
|
||
8 years ago
|
</Column>
|
||
|
);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
}
|