2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
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-06-09 21:47:12 +01:00
|
|
|
import { me } from '../initial_state'
|
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-06-09 21:47:12 +01:00
|
|
|
import Block from '../components/block'
|
2020-08-07 05:14:13 +01:00
|
|
|
import BlockHeading from '../components/block_heading'
|
2020-03-25 03:08:43 +00:00
|
|
|
import ScrollableList from '../components/scrollable_list'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
class MutedAccounts extends ImmutablePureComponent {
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
componentWillMount() {
|
2020-06-09 21:47:12 +01:00
|
|
|
this.props.onFetchMutes()
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleLoadMore = debounce(() => {
|
2020-06-09 21:47:12 +01:00
|
|
|
this.props.onExpandMutes()
|
2020-03-25 03:08:43 +00:00
|
|
|
}, 300, { leading: true })
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
render() {
|
2020-06-09 21:47:12 +01:00
|
|
|
const {
|
|
|
|
accountIds,
|
|
|
|
hasMore,
|
|
|
|
isLoading,
|
|
|
|
} = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-06-09 21:47:12 +01:00
|
|
|
<Block>
|
2020-08-07 05:14:13 +01:00
|
|
|
<BlockHeading title={<FormattedMessage id='navigation_bar.mutes' defaultMessage='Muted users' />} />
|
2020-06-09 21:47:12 +01:00
|
|
|
<ScrollableList
|
|
|
|
scrollKey='mutes'
|
|
|
|
onLoadMore={this.handleLoadMore}
|
|
|
|
hasMore={hasMore}
|
|
|
|
isLoading={isLoading}
|
|
|
|
emptyMessage={<FormattedMessage id='empty_column.mutes' defaultMessage="You haven't muted any users yet." />}
|
|
|
|
>
|
|
|
|
{
|
2020-06-10 21:05:15 +01:00
|
|
|
accountIds && accountIds.map((id) =>
|
2020-06-09 21:47:12 +01:00
|
|
|
<Account
|
|
|
|
key={`mutes-${id}`}
|
|
|
|
id={id}
|
|
|
|
compact
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</ScrollableList>
|
|
|
|
</Block>
|
2020-02-24 23:25:55 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-19 01:22:15 +01:00
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
accountIds: state.getIn(['user_lists', 'mutes', me, 'items']),
|
|
|
|
hasMore: !!state.getIn(['user_lists', 'mutes', me, 'next']),
|
|
|
|
isLoading: state.getIn(['user_lists', 'mutes', me, 'isLoading']),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onFetchMutes: () => dispatch(fetchMutes()),
|
|
|
|
onExpandMutes: () => dispatch(expandMutes()),
|
|
|
|
})
|
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
MutedAccounts.propTypes = {
|
2020-08-19 01:22:15 +01:00
|
|
|
accountIds: ImmutablePropTypes.list,
|
|
|
|
hasMore: PropTypes.bool,
|
|
|
|
isLoading: PropTypes.bool,
|
|
|
|
onExpandMutes: PropTypes.func.isRequired,
|
|
|
|
onFetchMutes: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
2020-12-03 04:22:51 +00:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(MutedAccounts))
|