|
|
@ -8,7 +8,9 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
|
|
|
|
import { fetchFavourites } from 'flavours/glitch/actions/interactions';
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { fetchFavourites, expandFavourites } from 'flavours/glitch/actions/interactions';
|
|
|
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
|
|
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
|
|
|
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';
|
|
|
|
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';
|
|
|
@ -23,7 +25,9 @@ const messages = defineMessages({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId]),
|
|
|
|
accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'items']),
|
|
|
|
|
|
|
|
hasMore: !!state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'next']),
|
|
|
|
|
|
|
|
isLoading: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'isLoading'], true),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
class Favourites extends ImmutablePureComponent {
|
|
|
|
class Favourites extends ImmutablePureComponent {
|
|
|
@ -32,6 +36,8 @@ class Favourites extends ImmutablePureComponent {
|
|
|
|
params: PropTypes.object.isRequired,
|
|
|
|
params: PropTypes.object.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
accountIds: ImmutablePropTypes.list,
|
|
|
|
accountIds: ImmutablePropTypes.list,
|
|
|
|
|
|
|
|
hasMore: PropTypes.bool,
|
|
|
|
|
|
|
|
isLoading: PropTypes.bool,
|
|
|
|
multiColumn: PropTypes.bool,
|
|
|
|
multiColumn: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -42,12 +48,6 @@ class Favourites extends ImmutablePureComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
|
|
|
|
|
|
|
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
|
|
|
|
|
|
|
|
this.props.dispatch(fetchFavourites(nextProps.params.statusId));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleHeaderClick = () => {
|
|
|
|
handleHeaderClick = () => {
|
|
|
|
this.column.scrollTop();
|
|
|
|
this.column.scrollTop();
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -60,8 +60,12 @@ class Favourites extends ImmutablePureComponent {
|
|
|
|
this.props.dispatch(fetchFavourites(this.props.params.statusId));
|
|
|
|
this.props.dispatch(fetchFavourites(this.props.params.statusId));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleLoadMore = debounce(() => {
|
|
|
|
|
|
|
|
this.props.dispatch(expandFavourites(this.props.params.statusId));
|
|
|
|
|
|
|
|
}, 300, { leading: true });
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const { intl, accountIds, multiColumn } = this.props;
|
|
|
|
const { intl, accountIds, hasMore, isLoading, multiColumn } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
if (!accountIds) {
|
|
|
|
if (!accountIds) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -87,6 +91,9 @@ class Favourites extends ImmutablePureComponent {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<ScrollableList
|
|
|
|
<ScrollableList
|
|
|
|
scrollKey='favourites'
|
|
|
|
scrollKey='favourites'
|
|
|
|
|
|
|
|
onLoadMore={this.handleLoadMore}
|
|
|
|
|
|
|
|
hasMore={hasMore}
|
|
|
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
emptyMessage={emptyMessage}
|
|
|
|
emptyMessage={emptyMessage}
|
|
|
|
bindToDocument={!multiColumn}
|
|
|
|
bindToDocument={!multiColumn}
|
|
|
|
>
|
|
|
|
>
|
|
|
|