The code powering m.abunchtell.com https://m.abunchtell.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

90 řádky
2.8 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import ImmutablePureComponent from 'react-immutable-pure-component';
  4. import PropTypes from 'prop-types';
  5. import ImmutablePropTypes from 'react-immutable-proptypes';
  6. import LoadingIndicator from '../../components/loading_indicator';
  7. import { fetchReblogs } from '../../actions/interactions';
  8. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  9. import AccountContainer from '../../containers/account_container';
  10. import Column from '../ui/components/column';
  11. import ScrollableList from '../../components/scrollable_list';
  12. import Icon from 'mastodon/components/icon';
  13. import ColumnHeader from '../../components/column_header';
  14. const messages = defineMessages({
  15. refresh: { id: 'refresh', defaultMessage: 'Refresh' },
  16. });
  17. const mapStateToProps = (state, props) => ({
  18. accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId]),
  19. });
  20. export default @connect(mapStateToProps)
  21. @injectIntl
  22. class Reblogs extends ImmutablePureComponent {
  23. static propTypes = {
  24. params: PropTypes.object.isRequired,
  25. dispatch: PropTypes.func.isRequired,
  26. shouldUpdateScroll: PropTypes.func,
  27. accountIds: ImmutablePropTypes.list,
  28. multiColumn: PropTypes.bool,
  29. intl: PropTypes.object.isRequired,
  30. };
  31. componentWillMount () {
  32. if (!this.props.accountIds) {
  33. this.props.dispatch(fetchReblogs(this.props.params.statusId));
  34. }
  35. }
  36. componentWillReceiveProps(nextProps) {
  37. if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
  38. this.props.dispatch(fetchReblogs(nextProps.params.statusId));
  39. }
  40. }
  41. handleRefresh = () => {
  42. this.props.dispatch(fetchReblogs(this.props.params.statusId));
  43. }
  44. render () {
  45. const { intl, shouldUpdateScroll, accountIds, multiColumn } = this.props;
  46. if (!accountIds) {
  47. return (
  48. <Column>
  49. <LoadingIndicator />
  50. </Column>
  51. );
  52. }
  53. const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has boosted this toot yet. When someone does, they will show up here.' />;
  54. return (
  55. <Column bindToDocument={!multiColumn}>
  56. <ColumnHeader
  57. showBackButton
  58. multiColumn={multiColumn}
  59. extraButton={(
  60. <button className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleRefresh}><Icon id='refresh' /></button>
  61. )}
  62. />
  63. <ScrollableList
  64. scrollKey='reblogs'
  65. shouldUpdateScroll={shouldUpdateScroll}
  66. emptyMessage={emptyMessage}
  67. bindToDocument={!multiColumn}
  68. >
  69. {accountIds.map(id =>
  70. <AccountContainer key={id} id={id} withNote={false} />
  71. )}
  72. </ScrollableList>
  73. </Column>
  74. );
  75. }
  76. }