1 import React
from 'react';
2 import { connect
} from 'react-redux';
3 import PropTypes
from 'prop-types';
4 import ImmutablePropTypes
from 'react-immutable-proptypes';
5 import LoadingIndicator
from 'flavours/glitch/components/loading_indicator';
6 import { ScrollContainer
} from 'react-router-scroll-4';
7 import Column
from 'flavours/glitch/features/ui/components/column';
8 import ColumnBackButtonSlim
from 'flavours/glitch/components/column_back_button_slim';
9 import AccountAuthorizeContainer
from './containers/account_authorize_container';
10 import { fetchFollowRequests
, expandFollowRequests
} from 'flavours/glitch/actions/accounts';
11 import { defineMessages
, injectIntl
} from 'react-intl';
12 import ImmutablePureComponent
from 'react-immutable-pure-component';
14 const messages
= defineMessages({
15 heading: { id: 'column.follow_requests', defaultMessage: 'Follow requests' },
18 const mapStateToProps
= state
=> ({
19 accountIds: state
.getIn(['user_lists', 'follow_requests', 'items']),
22 @connect(mapStateToProps
)
24 export default class FollowRequests
extends ImmutablePureComponent
{
27 params: PropTypes
.object
.isRequired
,
28 dispatch: PropTypes
.func
.isRequired
,
29 accountIds: ImmutablePropTypes
.list
,
30 intl: PropTypes
.object
.isRequired
,
33 componentWillMount () {
34 this.props
.dispatch(fetchFollowRequests());
37 handleScroll
= (e
) => {
38 const { scrollTop
, scrollHeight
, clientHeight
} = e
.target
;
40 if (scrollTop
=== scrollHeight
- clientHeight
) {
41 this.props
.dispatch(expandFollowRequests());
45 shouldUpdateScroll
= (prevRouterProps
, { location
}) => {
46 if ((((prevRouterProps
|| {}).location
|| {}).state
|| {}).mastodonModalOpen
) return false;
47 return !(location
.state
&& location
.state
.mastodonModalOpen
);
51 const { intl
, accountIds
} = this.props
;
55 <Column name
='follow-requests'>
62 <Column name
='follow-requests' icon
='users' heading
={intl
.formatMessage(messages
.heading
)}>
63 <ColumnBackButtonSlim
/>
65 <ScrollContainer scrollKey
='follow_requests' shouldUpdateScroll
={this.shouldUpdateScroll
}>
66 <div className
='scrollable' onScroll
={this.handleScroll
}>
68 <AccountAuthorizeContainer key
={id
} id
={id
} />