92 lines
2.6 KiB
JavaScript
92 lines
2.6 KiB
JavaScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import PropTypes from 'prop-types';
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
|
|
import IconButton from 'soapbox/components/icon_button';
|
|
import LoadingIndicator from 'soapbox/components/loading_indicator';
|
|
import AccountContainer from 'soapbox/containers/account_container';
|
|
import ScrollableList from 'soapbox/components/scrollable_list';
|
|
import { fetchReblogs } from 'soapbox/actions/interactions';
|
|
import { fetchStatus } from 'soapbox/actions/statuses';
|
|
|
|
const messages = defineMessages({
|
|
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
|
});
|
|
|
|
const mapStateToProps = (state, props) => {
|
|
return {
|
|
accountIds: state.getIn(['user_lists', 'reblogged_by', props.statusId]),
|
|
};
|
|
};
|
|
|
|
export default @connect(mapStateToProps)
|
|
@injectIntl
|
|
class ReblogsModal extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
onClose: PropTypes.func.isRequired,
|
|
intl: PropTypes.object.isRequired,
|
|
statusId: PropTypes.string.isRequired,
|
|
username: PropTypes.string.isRequired,
|
|
dispatch: PropTypes.func.isRequired,
|
|
accountIds: ImmutablePropTypes.orderedSet,
|
|
};
|
|
|
|
fetchData = () => {
|
|
const { dispatch, statusId } = this.props;
|
|
|
|
dispatch(fetchReblogs(statusId));
|
|
dispatch(fetchStatus(statusId));
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.fetchData();
|
|
}
|
|
|
|
onClickClose = () => {
|
|
this.props.onClose('REBLOGS');
|
|
};
|
|
|
|
render() {
|
|
const { intl, accountIds } = this.props;
|
|
|
|
let body;
|
|
|
|
if (!accountIds) {
|
|
body = <LoadingIndicator />;
|
|
} else {
|
|
const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has reposted this post yet. When someone does, they will show up here.' />;
|
|
|
|
body = (
|
|
<ScrollableList
|
|
scrollKey='reblogs'
|
|
emptyMessage={emptyMessage}
|
|
>
|
|
{accountIds.map(id =>
|
|
<AccountContainer key={id} id={id} withNote={false} />,
|
|
)}
|
|
</ScrollableList>
|
|
);
|
|
}
|
|
|
|
|
|
return (
|
|
<div className='modal-root__modal reactions-modal'>
|
|
<div className='compose-modal__header'>
|
|
<h3 className='compose-modal__header__title'>
|
|
<FormattedMessage id='column.reblogs' defaultMessage='Reposts' />
|
|
</h3>
|
|
<IconButton
|
|
className='compose-modal__close'
|
|
title={intl.formatMessage(messages.close)}
|
|
src={require('@tabler/icons/icons/x.svg')}
|
|
onClick={this.onClickClose} size={20}
|
|
/>
|
|
</div>
|
|
{body}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
}
|