You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
![]()
7 years ago
|
import React from 'react';
|
||
![]()
8 years ago
|
import { connect } from 'react-redux';
|
||
![]()
7 years ago
|
import PropTypes from 'prop-types';
|
||
![]()
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
![]()
7 years ago
|
import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
|
||
|
import { fetchFavourites } from 'flavours/glitch/actions/interactions';
|
||
![]()
7 years ago
|
import { ScrollContainer } from 'react-router-scroll-4';
|
||
![]()
7 years ago
|
import AccountContainer from 'flavours/glitch/containers/account_container';
|
||
|
import Column from 'flavours/glitch/features/ui/components/column';
|
||
|
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
|
||
![]()
7 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
![]()
8 years ago
|
|
||
|
const mapStateToProps = (state, props) => ({
|
||
![]()
7 years ago
|
accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId]),
|
||
![]()
8 years ago
|
});
|
||
|
|
||
![]()
7 years ago
|
@connect(mapStateToProps)
|
||
|
export default class Favourites extends ImmutablePureComponent {
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
static propTypes = {
|
||
|
params: PropTypes.object.isRequired,
|
||
|
dispatch: PropTypes.func.isRequired,
|
||
![]()
7 years ago
|
accountIds: ImmutablePropTypes.list,
|
||
![]()
7 years ago
|
};
|
||
|
|
||
![]()
8 years ago
|
componentWillMount () {
|
||
![]()
7 years ago
|
this.props.dispatch(fetchFavourites(this.props.params.statusId));
|
||
![]()
7 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
componentWillReceiveProps (nextProps) {
|
||
![]()
8 years ago
|
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
|
||
![]()
7 years ago
|
this.props.dispatch(fetchFavourites(nextProps.params.statusId));
|
||
![]()
8 years ago
|
}
|
||
![]()
7 years ago
|
}
|
||
![]()
8 years ago
|
|
||
|
render () {
|
||
|
const { accountIds } = this.props;
|
||
|
|
||
|
if (!accountIds) {
|
||
|
return (
|
||
|
<Column>
|
||
|
<LoadingIndicator />
|
||
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<Column>
|
||
|
<ColumnBackButton />
|
||
|
|
||
|
<ScrollContainer scrollKey='favourites'>
|
||
|
<div className='scrollable'>
|
||
|
{accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
|
||
|
</div>
|
||
|
</ScrollContainer>
|
||
|
</Column>
|
||
|
);
|
||
|
}
|
||
|
|
||
![]()
7 years ago
|
}
|