Skip to content

Commit b701bba

Browse files
Gargronhiyuki2578
authored andcommitted
Add refresh button to list of rebloggers/favouriters in web UI (mastodon#12031)
1 parent 976d968 commit b701bba

2 files changed

Lines changed: 44 additions & 10 deletions

File tree

app/javascript/mastodon/features/favourites/index.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ import PropTypes from 'prop-types';
55
import ImmutablePropTypes from 'react-immutable-proptypes';
66
import LoadingIndicator from '../../components/loading_indicator';
77
import { fetchFavourites } from '../../actions/interactions';
8-
import { FormattedMessage } from 'react-intl';
8+
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
99
import AccountContainer from '../../containers/account_container';
1010
import Column from '../ui/components/column';
11-
import ColumnBackButton from '../../components/column_back_button';
1211
import ScrollableList from '../../components/scrollable_list';
12+
import Icon from 'mastodon/components/icon';
13+
import ColumnHeader from '../../components/column_header';
14+
15+
const messages = defineMessages({
16+
refresh: { id: 'refresh', defaultMessage: 'Refresh' },
17+
});
1318

1419
const mapStateToProps = (state, props) => ({
1520
accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId]),
1621
});
1722

1823
export default @connect(mapStateToProps)
24+
@injectIntl
1925
class Favourites extends ImmutablePureComponent {
2026

2127
static propTypes = {
@@ -24,6 +30,7 @@ class Favourites extends ImmutablePureComponent {
2430
shouldUpdateScroll: PropTypes.func,
2531
accountIds: ImmutablePropTypes.list,
2632
multiColumn: PropTypes.bool,
33+
intl: PropTypes.object.isRequired,
2734
};
2835

2936
componentWillMount () {
@@ -38,8 +45,12 @@ class Favourites extends ImmutablePureComponent {
3845
}
3946
}
4047

48+
handleRefresh = () => {
49+
this.props.dispatch(fetchFavourites(this.props.params.statusId));
50+
}
51+
4152
render () {
42-
const { shouldUpdateScroll, accountIds, multiColumn } = this.props;
53+
const { intl, shouldUpdateScroll, accountIds, multiColumn } = this.props;
4354

4455
if (!accountIds) {
4556
return (
@@ -52,8 +63,14 @@ class Favourites extends ImmutablePureComponent {
5263
const emptyMessage = <FormattedMessage id='empty_column.favourites' defaultMessage='No one has favourited this toot yet. When someone does, they will show up here.' />;
5364

5465
return (
55-
<Column>
56-
<ColumnBackButton multiColumn={multiColumn} />
66+
<Column bindToDocument={!multiColumn}>
67+
<ColumnHeader
68+
showBackButton
69+
multiColumn={multiColumn}
70+
extraButton={(
71+
<button className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleRefresh}><Icon id='refresh' /></button>
72+
)}
73+
/>
5774

5875
<ScrollableList
5976
scrollKey='favourites'

app/javascript/mastodon/features/reblogs/index.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ import PropTypes from 'prop-types';
55
import ImmutablePropTypes from 'react-immutable-proptypes';
66
import LoadingIndicator from '../../components/loading_indicator';
77
import { fetchReblogs } from '../../actions/interactions';
8-
import { FormattedMessage } from 'react-intl';
8+
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
99
import AccountContainer from '../../containers/account_container';
1010
import Column from '../ui/components/column';
11-
import ColumnBackButton from '../../components/column_back_button';
1211
import ScrollableList from '../../components/scrollable_list';
12+
import Icon from 'mastodon/components/icon';
13+
import ColumnHeader from '../../components/column_header';
14+
15+
const messages = defineMessages({
16+
refresh: { id: 'refresh', defaultMessage: 'Refresh' },
17+
});
1318

1419
const mapStateToProps = (state, props) => ({
1520
accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId]),
1621
});
1722

1823
export default @connect(mapStateToProps)
24+
@injectIntl
1925
class Reblogs extends ImmutablePureComponent {
2026

2127
static propTypes = {
@@ -24,6 +30,7 @@ class Reblogs extends ImmutablePureComponent {
2430
shouldUpdateScroll: PropTypes.func,
2531
accountIds: ImmutablePropTypes.list,
2632
multiColumn: PropTypes.bool,
33+
intl: PropTypes.object.isRequired,
2734
};
2835

2936
componentWillMount () {
@@ -38,8 +45,12 @@ class Reblogs extends ImmutablePureComponent {
3845
}
3946
}
4047

48+
handleRefresh = () => {
49+
this.props.dispatch(fetchReblogs(this.props.params.statusId));
50+
}
51+
4152
render () {
42-
const { shouldUpdateScroll, accountIds, multiColumn } = this.props;
53+
const { intl, shouldUpdateScroll, accountIds, multiColumn } = this.props;
4354

4455
if (!accountIds) {
4556
return (
@@ -52,8 +63,14 @@ class Reblogs extends ImmutablePureComponent {
5263
const emptyMessage = <FormattedMessage id='status.reblogs.empty' defaultMessage='No one has boosted this toot yet. When someone does, they will show up here.' />;
5364

5465
return (
55-
<Column>
56-
<ColumnBackButton multiColumn={multiColumn} />
66+
<Column bindToDocument={!multiColumn}>
67+
<ColumnHeader
68+
showBackButton
69+
multiColumn={multiColumn}
70+
extraButton={(
71+
<button className='column-header__button' title={intl.formatMessage(messages.refresh)} aria-label={intl.formatMessage(messages.refresh)} onClick={this.handleRefresh}><Icon id='refresh' /></button>
72+
)}
73+
/>
5774

5875
<ScrollableList
5976
scrollKey='reblogs'

0 commit comments

Comments
 (0)