2020-03-25 03:08:43 +00:00
|
|
|
import { injectIntl, FormattedMessage } from 'react-intl'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
2020-04-08 02:06:59 +01:00
|
|
|
import debounce from 'lodash.debounce'
|
2020-03-25 03:08:43 +00:00
|
|
|
import { fetchMutes, expandMutes } from '../actions/mutes'
|
2020-04-11 23:29:19 +01:00
|
|
|
import Account from '../components/account'
|
2020-03-25 03:08:43 +00:00
|
|
|
import ScrollableList from '../components/scrollable_list'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const mapStateToProps = (state) => ({
|
2019-08-07 06:02:36 +01:00
|
|
|
accountIds: state.getIn(['user_lists', 'mutes', 'items']),
|
|
|
|
hasMore: !!state.getIn(['user_lists', 'mutes', 'next']),
|
2020-05-01 06:50:27 +01:00
|
|
|
isLoading: state.getIn(['user_lists', 'mutes', 'isLoading'], true),
|
2020-03-25 03:08:43 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-02-25 16:04:44 +00:00
|
|
|
export default
|
|
|
|
@connect(mapStateToProps)
|
2019-08-07 06:02:36 +01:00
|
|
|
@injectIntl
|
|
|
|
class Mutes extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
params: PropTypes.object.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
hasMore: PropTypes.bool,
|
|
|
|
accountIds: ImmutablePropTypes.list,
|
2020-05-01 06:50:27 +01:00
|
|
|
isLoading: PropTypes.bool,
|
2020-03-25 03:08:43 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
componentWillMount() {
|
2020-03-25 03:08:43 +00:00
|
|
|
this.props.dispatch(fetchMutes())
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleLoadMore = debounce(() => {
|
2020-03-25 03:08:43 +00:00
|
|
|
this.props.dispatch(expandMutes())
|
|
|
|
}, 300, { leading: true })
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
render() {
|
2020-05-01 06:50:27 +01:00
|
|
|
const { hasMore, accountIds, isLoading } = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-02-24 23:25:55 +00:00
|
|
|
<ScrollableList
|
|
|
|
scrollKey='mutes'
|
|
|
|
onLoadMore={this.handleLoadMore}
|
|
|
|
hasMore={hasMore}
|
2020-05-01 06:50:27 +01:00
|
|
|
isLoading={isLoading}
|
2020-02-24 23:25:55 +00:00
|
|
|
emptyMessage={<FormattedMessage id='empty_column.mutes' defaultMessage="You haven't muted any users yet." />}
|
|
|
|
>
|
2020-03-04 23:08:08 +00:00
|
|
|
{
|
2020-05-01 06:50:27 +01:00
|
|
|
accountIds && accountIds.map(id =>
|
2020-04-11 23:29:19 +01:00
|
|
|
<Account key={`mutes-${id}`} id={id} compact />
|
2020-03-04 23:08:08 +00:00
|
|
|
)
|
|
|
|
}
|
2020-02-24 23:25:55 +00:00
|
|
|
</ScrollableList>
|
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|