mirror of https://github.com/mastodon/mastodon
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 optionpull/125/head
parent
61db14bcbe
commit
f8f40f15da
@ -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);
|
@ -1,57 +1,17 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import StatusList from '../../../components/status_list';
|
import StatusList from '../../../components/status_list';
|
||||||
import { replyCompose } from '../../../actions/compose';
|
|
||||||
import {
|
|
||||||
reblog,
|
|
||||||
favourite,
|
|
||||||
unreblog,
|
|
||||||
unfavourite
|
|
||||||
} from '../../../actions/interactions';
|
|
||||||
import { expandTimeline } from '../../../actions/timelines';
|
import { expandTimeline } from '../../../actions/timelines';
|
||||||
import { makeGetTimeline } from '../../../selectors';
|
|
||||||
import { deleteStatus } from '../../../actions/statuses';
|
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
const mapStateToProps = (state, props) => ({
|
||||||
const getTimeline = makeGetTimeline();
|
statusIds: state.getIn(['timelines', props.type])
|
||||||
|
});
|
||||||
const mapStateToProps = (state, props) => ({
|
|
||||||
statuses: getTimeline(state, props.type),
|
|
||||||
me: state.getIn(['timelines', 'me'])
|
|
||||||
});
|
|
||||||
|
|
||||||
return mapStateToProps;
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapDispatchToProps = function (dispatch, props) {
|
const mapDispatchToProps = function (dispatch, props) {
|
||||||
return {
|
return {
|
||||||
onReply (status) {
|
|
||||||
dispatch(replyCompose(status));
|
|
||||||
},
|
|
||||||
|
|
||||||
onFavourite (status) {
|
|
||||||
if (status.get('favourited')) {
|
|
||||||
dispatch(unfavourite(status));
|
|
||||||
} else {
|
|
||||||
dispatch(favourite(status));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onReblog (status) {
|
|
||||||
if (status.get('reblogged')) {
|
|
||||||
dispatch(unreblog(status));
|
|
||||||
} else {
|
|
||||||
dispatch(reblog(status));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onScrollToBottom () {
|
onScrollToBottom () {
|
||||||
dispatch(expandTimeline(props.type));
|
dispatch(expandTimeline(props.type));
|
||||||
},
|
|
||||||
|
|
||||||
onDelete (status) {
|
|
||||||
dispatch(deleteStatus(status.get('id')));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);
|
export default connect(mapStateToProps, mapDispatchToProps)(StatusList);
|
||||||
|
Loading…
Reference in New Issue