2016-09-01 07:21:48 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import StatusList from '../components/status_list';
|
|
|
|
import { replyCompose } from '../actions/compose';
|
|
|
|
import { reblog, favourite } from '../actions/interactions';
|
2016-08-24 11:56:44 -04:00
|
|
|
|
2016-09-04 08:04:26 -04:00
|
|
|
function selectStatus(state, id) {
|
|
|
|
let status = state.getIn(['timelines', 'statuses', id]);
|
|
|
|
|
|
|
|
status = status.set('account', state.getIn(['timelines', 'accounts', status.get('account')]));
|
|
|
|
|
|
|
|
if (status.get('reblog') !== null) {
|
|
|
|
status = status.set('reblog', selectStatus(state, status.get('reblog')));
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
};
|
|
|
|
|
2016-08-24 11:56:44 -04:00
|
|
|
const mapStateToProps = function (state, props) {
|
|
|
|
return {
|
2016-09-04 08:04:26 -04:00
|
|
|
statuses: state.getIn(['timelines', props.type]).map(id => selectStatus(state, id))
|
2016-08-24 11:56:44 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-08-31 16:58:10 -04:00
|
|
|
const mapDispatchToProps = function (dispatch) {
|
|
|
|
return {
|
|
|
|
onReply: function (status) {
|
|
|
|
dispatch(replyCompose(status));
|
2016-09-01 07:21:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onFavourite: function (status) {
|
|
|
|
dispatch(favourite(status));
|
|
|
|
},
|
|
|
|
|
|
|
|
onReblog: function (status) {
|
|
|
|
dispatch(reblog(status));
|
2016-08-31 16:58:10 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(StatusList);
|