pleroma/app/soapbox/features/compose/containers/reply_mentions_container.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-01-04 12:06:08 -08:00
import { connect } from 'react-redux';
import { openModal } from 'soapbox/actions/modals';
import { statusToMentionsAccountIdsArray } from 'soapbox/reducers/compose';
import { makeGetStatus } from 'soapbox/selectors';
2022-01-04 12:06:08 -08:00
import { getFeatures } from 'soapbox/utils/features';
2022-01-04 12:06:08 -08:00
import ReplyMentions from '../components/reply_mentions';
const makeMapStateToProps = () => {
const getStatus = makeGetStatus();
return state => {
const instance = state.get('instance');
const { explicitAddressing } = getFeatures(instance);
if (!explicitAddressing) {
return {
explicitAddressing: false,
};
}
const status = getStatus(state, { id: state.getIn(['compose', 'in_reply_to']) });
if (!status) {
return {
isReply: false,
};
}
const to = state.getIn(['compose', 'to']);
const me = state.get('me');
const account = state.getIn(['accounts', me]);
const parentTo = statusToMentionsAccountIdsArray(state, status, account);
2022-01-04 12:06:08 -08:00
return {
to,
parentTo,
2022-01-04 12:06:08 -08:00
isReply: true,
explicitAddressing: true,
};
};
};
const mapDispatchToProps = dispatch => ({
onOpenMentionsModal() {
dispatch(openModal('REPLY_MENTIONS'));
2022-01-04 12:06:08 -08:00
},
});
export default connect(makeMapStateToProps, mapDispatchToProps)(ReplyMentions);