2020-05-01 06:50:27 +01:00
import { defineMessages , 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-05-01 06:50:27 +01:00
import { me } from '../../initial_state'
import { fetchFollowRequests , expandFollowRequests } from '../../actions/accounts'
import AccountAuthorize from './components/account_authorize'
import ScrollableList from '../../components/scrollable_list'
2019-08-13 16:54:29 +01:00
const messages = defineMessages ( {
heading : { id : 'column.follow_requests' , defaultMessage : 'Follow requests' } ,
2020-05-01 06:50:27 +01:00
} )
2019-08-13 16:54:29 +01:00
2020-04-11 23:29:19 +01:00
const mapStateToProps = ( state ) => ( {
2019-08-13 16:54:29 +01:00
accountIds : state . getIn ( [ 'user_lists' , 'follow_requests' , 'items' ] ) ,
2020-05-01 06:50:27 +01:00
isLoading : state . getIn ( [ 'user_lists' , 'follow_requests' , 'isLoading' ] , true ) ,
2019-08-13 16:54:29 +01:00
hasMore : ! ! state . getIn ( [ 'user_lists' , 'follow_requests' , 'next' ] ) ,
2020-05-01 06:50:27 +01:00
locked : ! ! state . getIn ( [ 'accounts' , me , 'locked' ] ) ,
domain : state . getIn ( [ 'meta' , 'domain' ] ) ,
} )
2019-08-13 16:54:29 +01:00
2020-02-25 16:04:44 +00:00
export default
@ connect ( mapStateToProps )
2019-08-13 16:54:29 +01:00
@ injectIntl
class FollowRequests extends ImmutablePureComponent {
static propTypes = {
params : PropTypes . object . isRequired ,
dispatch : PropTypes . func . isRequired ,
hasMore : PropTypes . bool ,
2020-05-01 06:50:27 +01:00
locked : PropTypes . bool ,
domain : PropTypes . string ,
isLoading : PropTypes . bool ,
2019-08-13 16:54:29 +01:00
accountIds : ImmutablePropTypes . list ,
intl : PropTypes . object . isRequired ,
2020-05-01 06:50:27 +01:00
}
2019-08-13 16:54:29 +01:00
componentWillMount ( ) {
2020-05-01 06:50:27 +01:00
this . props . dispatch ( fetchFollowRequests ( ) )
2019-08-13 16:54:29 +01:00
}
handleLoadMore = debounce ( ( ) => {
2020-05-01 06:50:27 +01:00
this . props . dispatch ( expandFollowRequests ( ) )
} , 300 , { leading : true } )
2019-08-13 16:54:29 +01:00
render ( ) {
2020-05-01 06:50:27 +01:00
const { intl , accountIds , hasMore , locked , domain , isLoading } = this . props
2019-08-13 16:54:29 +01:00
2020-05-01 06:50:27 +01:00
// : todo :
const unlockedPrependMessage = locked ? null : (
< div className = 'follow_requests-unlocked_explanation' >
< FormattedMessage
id = 'follow_requests.unlocked_explanation'
defaultMessage = 'Even though your account is not locked, the {domain} staff thought you might want to review follow requests from these accounts manually.'
values = { { domain : domain } }
/ >
< / d i v >
) ;
2019-08-13 16:54:29 +01:00
return (
2020-02-24 23:25:55 +00:00
< ScrollableList
scrollKey = 'follow_requests'
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.follow_requests' defaultMessage = "You don't have any follow requests yet. When you receive one, it will show up here." / > }
>
2020-05-01 06:50:27 +01:00
{
! ! accountIds && accountIds . map ( id =>
< AccountAuthorize key = { id } id = { id } / >
)
}
2020-02-24 23:25:55 +00:00
< / S c r o l l a b l e L i s t >
2019-08-13 16:54:29 +01:00
) ;
}
}