Updated UnfollowModal
• Updated: - UnfollowModal to fix the issue with people with it enabled being unable to unfollow others - All instances of instantiating the UnfollowModal to pass in account instead of accountId
This commit is contained in:
parent
03e28831f3
commit
dd00db13bc
@ -31,7 +31,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||||
if (unfollowModal) {
|
if (unfollowModal) {
|
||||||
dispatch(openModal('UNFOLLOW', {
|
dispatch(openModal('UNFOLLOW', {
|
||||||
accountId: account.get('id'),
|
account,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
dispatch(unfollowAccount(account.get('id')))
|
dispatch(unfollowAccount(account.get('id')))
|
||||||
|
@ -30,7 +30,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||||
if (unfollowModal) {
|
if (unfollowModal) {
|
||||||
dispatch(openModal('UNFOLLOW', {
|
dispatch(openModal('UNFOLLOW', {
|
||||||
accountId: account.get('id'),
|
account,
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
dispatch(unfollowAccount(account.get('id')));
|
dispatch(unfollowAccount(account.get('id')));
|
||||||
|
@ -1,43 +1,29 @@
|
|||||||
import { injectIntl, defineMessages } from 'react-intl'
|
import { FormattedMessage } from 'react-intl'
|
||||||
import { muteAccount } from '../../actions/accounts'
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
||||||
const messages = defineMessages({
|
import { unfollowAccount } from '../../actions/accounts'
|
||||||
muteMessage: { id: 'confirmations.mute.message', defaultMessage: 'Are you sure you want to mute {name}?' },
|
import ConfirmationModal from './confirmation_modal'
|
||||||
cancel: { id: 'confirmation_modal.cancel', defaultMessage: 'Cancel' },
|
|
||||||
confirm: { id: 'confirmations.mute.confirm', defaultMessage: 'Mute' },
|
|
||||||
})
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
|
||||||
isSubmitting: state.getIn(['reports', 'new', 'isSubmitting']),
|
|
||||||
account: state.getIn(['mutes', 'new', 'account']),
|
|
||||||
})
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
onConfirm(account, notifications) {
|
onConfirm(accountId) {
|
||||||
dispatch(muteAccount(account.get('id'), notifications))
|
dispatch(unfollowAccount(accountId))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default
|
export default
|
||||||
@connect(mapStateToProps, mapDispatchToProps)
|
@connect(null, mapDispatchToProps)
|
||||||
@injectIntl
|
class UnfollowModal extends ImmutablePureComponent {
|
||||||
class UnfollowModal extends PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
isSubmitting: PropTypes.bool.isRequired,
|
isSubmitting: PropTypes.bool.isRequired,
|
||||||
account: PropTypes.object.isRequired,
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.button.focus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
this.props.onClose()
|
this.props.onClose()
|
||||||
this.props.onConfirm(this.props.account, this.props.notifications)
|
this.props.onConfirm(this.props.account.get('id'))
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCancel = () => {
|
handleCancel = () => {
|
||||||
@ -45,25 +31,15 @@ class UnfollowModal extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, intl } = this.props
|
const { account } = this.props
|
||||||
|
|
||||||
// : TODO :
|
|
||||||
// , {
|
|
||||||
// message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
|
||||||
// confirm: intl.formatMessage(messages.unfollowConfirm),
|
|
||||||
// onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
|
|
||||||
// }));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
title={`Mute @${account.get('acct')}`}
|
title={`Unfollow @${account.get('acct')}`}
|
||||||
message={<FormattedMessage id='confirmations.mute.message' defaultMessage='Are you sure you want to mute @{name}?' values={{ name: account.get('acct') }} />}
|
message={<FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />}
|
||||||
confirm={<FormattedMessage id='mute' defaultMessage='Mute' />}
|
confirm={<FormattedMessage id='confirmations.unfollow.confirm' defaultMessage='Unfollow' />}
|
||||||
onClose={onClose}
|
onClose={this.handleCancel}
|
||||||
onConfirm={() => {
|
onConfirm={this.handleClick}
|
||||||
// dispatch(blockDomain(domain))
|
|
||||||
// dispatch(blockDomain(domain))
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import Text from '../text'
|
|||||||
import List from '../list'
|
import List from '../list'
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
|
||||||
blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' },
|
blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' },
|
||||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||||
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||||
@ -66,7 +65,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||||
if (unfollowModal) {
|
if (unfollowModal) {
|
||||||
dispatch(openModal('UNFOLLOW', {
|
dispatch(openModal('UNFOLLOW', {
|
||||||
accountId: account.get('id'),
|
account,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
dispatch(unfollowAccount(account.get('id')))
|
dispatch(unfollowAccount(account.get('id')))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user