2016-10-24 18:11:02 +03:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Status from '../components/status';
|
|
|
|
import { makeGetStatus } from '../selectors';
|
|
|
|
import {
|
|
|
|
replyCompose,
|
|
|
|
mentionCompose
|
|
|
|
} from '../actions/compose';
|
|
|
|
import {
|
|
|
|
reblog,
|
|
|
|
favourite,
|
|
|
|
unreblog,
|
|
|
|
unfavourite
|
|
|
|
} from '../actions/interactions';
|
|
|
|
import { deleteStatus } from '../actions/statuses';
|
2016-10-24 19:07:40 +03:00
|
|
|
import { openMedia } from '../actions/modal';
|
2016-10-24 18:11:02 +03:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getStatus = makeGetStatus();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
status: getStatus(state, props.id),
|
2016-10-30 16:06:43 +02:00
|
|
|
me: state.getIn(['meta', 'me'])
|
2016-10-24 18:11:02 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
|
|
|
onReply (status) {
|
|
|
|
dispatch(replyCompose(status));
|
|
|
|
},
|
|
|
|
|
|
|
|
onReblog (status) {
|
|
|
|
if (status.get('reblogged')) {
|
|
|
|
dispatch(unreblog(status));
|
|
|
|
} else {
|
|
|
|
dispatch(reblog(status));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onFavourite (status) {
|
|
|
|
if (status.get('favourited')) {
|
|
|
|
dispatch(unfavourite(status));
|
|
|
|
} else {
|
|
|
|
dispatch(favourite(status));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDelete (status) {
|
|
|
|
dispatch(deleteStatus(status.get('id')));
|
|
|
|
},
|
|
|
|
|
|
|
|
onMention (account) {
|
|
|
|
dispatch(mentionCompose(account));
|
2016-10-24 19:07:40 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onOpenMedia (url) {
|
|
|
|
dispatch(openMedia(url));
|
2016-10-24 18:11:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Status);
|