2020-05-01 06:50:27 +01:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import { quoteCompose } from '../../actions/compose'
|
|
|
|
import { repost, unrepost } from '../../actions/interactions'
|
|
|
|
import { openModal } from '../../actions/modal'
|
|
|
|
import { boostModal, me } from '../../initial_state'
|
2020-04-28 06:33:58 +01:00
|
|
|
import PopoverLayout from './popover_layout'
|
2020-05-01 06:50:27 +01:00
|
|
|
import List from '../list'
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
repost: { id: 'repost', defaultMessage: 'Repost' },
|
|
|
|
repostWithComment: { id: 'repost_with_comment', defaultMessage: 'Repost with comment' },
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
|
|
|
onQuote (status, router) {
|
|
|
|
if (!me) return dispatch(openModal('UNAUTHORIZED'))
|
|
|
|
|
|
|
|
dispatch((_, getState) => {
|
|
|
|
const state = getState();
|
|
|
|
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: intl.formatMessage(messages.quoteMessage),
|
|
|
|
confirm: intl.formatMessage(messages.quoteConfirm),
|
|
|
|
onConfirm: () => dispatch(quoteCompose(status, router)),
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
dispatch(quoteCompose(status, router));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onRepost (status) {
|
|
|
|
if (!me) return dispatch(openModal('UNAUTHORIZED'))
|
|
|
|
|
|
|
|
if (status.get('reblogged')) {
|
|
|
|
dispatch(unrepost(status));
|
|
|
|
} else {
|
|
|
|
dispatch(repost(status));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
export default
|
|
|
|
@injectIntl
|
|
|
|
@connect(null, mapDispatchToProps)
|
|
|
|
class GroupOptionsPopover extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
onQuote: PropTypes.func.isRequired,
|
|
|
|
onRepost: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
updateOnProps = ['status']
|
|
|
|
|
|
|
|
handleOnRepost = () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
handleOnQuote = () => {
|
|
|
|
|
|
|
|
}
|
2020-04-28 06:33:58 +01:00
|
|
|
|
|
|
|
render() {
|
2020-05-01 06:50:27 +01:00
|
|
|
const { intl } = this.props
|
|
|
|
|
|
|
|
const listItems = [
|
|
|
|
{
|
|
|
|
hideArrow: true,
|
|
|
|
icon: 'repost',
|
|
|
|
title: intl.formatMessage(messages.repost),
|
|
|
|
onClick: this.handleOnRepost,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
hideArrow: true,
|
|
|
|
icon: 'pencil',
|
|
|
|
title: intl.formatMessage(messages.repostWithComment),
|
|
|
|
onClick: this.handleBlockDomain,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2020-04-28 06:33:58 +01:00
|
|
|
return (
|
2020-05-04 19:44:37 +01:00
|
|
|
<PopoverLayout>
|
2020-05-01 06:50:27 +01:00
|
|
|
<List
|
|
|
|
scrollKey='repost_options'
|
|
|
|
items={listItems}
|
|
|
|
size='large'
|
|
|
|
/>
|
2020-04-28 06:33:58 +01:00
|
|
|
</PopoverLayout>
|
|
|
|
)
|
|
|
|
}
|
2020-05-01 06:50:27 +01:00
|
|
|
|
2020-04-28 06:33:58 +01:00
|
|
|
}
|