From f8f40f15dafca65dc07d5c5c19fb9a9dc3473dd6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 24 Oct 2016 17:11:02 +0200 Subject: Move status components inside individual containers. We still need to select all statuses/accounts to assemble, but at least lists don't have to be re-rendered all the time now. Also add "mention" dropdown option --- .../components/containers/status_container.jsx | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 app/assets/javascripts/components/containers/status_container.jsx (limited to 'app/assets/javascripts/components/containers') diff --git a/app/assets/javascripts/components/containers/status_container.jsx b/app/assets/javascripts/components/containers/status_container.jsx new file mode 100644 index 000000000..b4d3740d9 --- /dev/null +++ b/app/assets/javascripts/components/containers/status_container.jsx @@ -0,0 +1,59 @@ +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'; + +const makeMapStateToProps = () => { + const getStatus = makeGetStatus(); + + const mapStateToProps = (state, props) => ({ + status: getStatus(state, props.id), + me: state.getIn(['timelines', 'me']) + }); + + 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)); + } + +}); + +export default connect(makeMapStateToProps, mapDispatchToProps)(Status); -- cgit