chinwagsocial/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx

58 lines
1.4 KiB
React
Raw Normal View History

import { connect } from 'react-redux';
import StatusList from '../../../components/status_list';
import { replyCompose } from '../../../actions/compose';
import {
reblog,
favourite,
unreblog,
unfavourite
} from '../../../actions/interactions';
2016-09-22 09:08:35 +10:00
import { expandTimeline } from '../../../actions/timelines';
import { makeGetTimeline } from '../../../selectors';
2016-09-30 08:00:45 +10:00
import { deleteStatus } from '../../../actions/statuses';
const makeMapStateToProps = () => {
const getTimeline = makeGetTimeline();
const mapStateToProps = (state, props) => ({
statuses: getTimeline(state, props.type),
2016-09-30 08:00:45 +10:00
me: state.getIn(['timelines', 'me'])
});
return mapStateToProps;
};
2016-09-22 09:08:35 +10:00
const mapDispatchToProps = function (dispatch, props) {
2016-09-01 06:58:10 +10:00
return {
2016-09-30 08:00:45 +10:00
onReply (status) {
2016-09-01 06:58:10 +10:00
dispatch(replyCompose(status));
},
2016-09-30 08:00:45 +10:00
onFavourite (status) {
if (status.get('favourited')) {
dispatch(unfavourite(status));
} else {
dispatch(favourite(status));
}
},
2016-09-30 08:00:45 +10:00
onReblog (status) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
} else {
dispatch(reblog(status));
}
2016-09-22 09:08:35 +10:00
},
2016-09-30 08:00:45 +10:00
onScrollToBottom () {
2016-09-22 09:08:35 +10:00
dispatch(expandTimeline(props.type));
2016-09-30 08:00:45 +10:00
},
onDelete (status) {
dispatch(deleteStatus(status.get('id')));
2016-09-01 06:58:10 +10:00
}
};
};
export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);