Add unmute action to ActionButton
This commit is contained in:
parent
b66b68b37c
commit
870f78e413
1 changed files with 19 additions and 1 deletions
|
@ -10,6 +10,8 @@ import {
|
||||||
unfollowAccount,
|
unfollowAccount,
|
||||||
blockAccount,
|
blockAccount,
|
||||||
unblockAccount,
|
unblockAccount,
|
||||||
|
muteAccount,
|
||||||
|
unmuteAccount,
|
||||||
} from 'soapbox/actions/accounts';
|
} from 'soapbox/actions/accounts';
|
||||||
import { openModal } from 'soapbox/actions/modals';
|
import { openModal } from 'soapbox/actions/modals';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
@ -23,6 +25,7 @@ const messages = defineMessages({
|
||||||
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' },
|
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' },
|
||||||
requested_small: { id: 'account.requested_small', defaultMessage: 'Awaiting approval' },
|
requested_small: { id: 'account.requested_small', defaultMessage: 'Awaiting approval' },
|
||||||
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
||||||
|
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
||||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||||
blocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
blocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
||||||
});
|
});
|
||||||
|
@ -54,6 +57,14 @@ const mapDispatchToProps = (dispatch) => ({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onMute(account) {
|
||||||
|
if (account.getIn(['relationship', 'muting'])) {
|
||||||
|
dispatch(unmuteAccount(account.get('id')));
|
||||||
|
} else {
|
||||||
|
dispatch(muteAccount(account.get('id')));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onOpenUnauthorizedModal(account) {
|
onOpenUnauthorizedModal(account) {
|
||||||
dispatch(openModal('UNAUTHORIZED', {
|
dispatch(openModal('UNAUTHORIZED', {
|
||||||
action: 'FOLLOW',
|
action: 'FOLLOW',
|
||||||
|
@ -97,6 +108,10 @@ class ActionButton extends ImmutablePureComponent {
|
||||||
this.props.onBlock(this.props.account);
|
this.props.onBlock(this.props.account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMute = () => {
|
||||||
|
this.props.onMute(this.props.account);
|
||||||
|
}
|
||||||
|
|
||||||
handleRemoteFollow = () => {
|
handleRemoteFollow = () => {
|
||||||
this.props.onOpenUnauthorizedModal(this.props.account);
|
this.props.onOpenUnauthorizedModal(this.props.account);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +148,7 @@ class ActionButton extends ImmutablePureComponent {
|
||||||
} else if (account.getIn(['relationship', 'requested'])) {
|
} else if (account.getIn(['relationship', 'requested'])) {
|
||||||
// Awaiting acceptance
|
// Awaiting acceptance
|
||||||
return <Button size='sm' theme='secondary' text={small ? intl.formatMessage(messages.requested_small) : intl.formatMessage(messages.requested)} onClick={this.handleFollow} />;
|
return <Button size='sm' theme='secondary' text={small ? intl.formatMessage(messages.requested_small) : intl.formatMessage(messages.requested)} onClick={this.handleFollow} />;
|
||||||
} else if (!account.getIn(['relationship', 'blocking'])) {
|
} else if (!account.getIn(['relationship', 'blocking']) && !account.getIn(['relationship', 'muting'])) {
|
||||||
// Follow & Unfollow
|
// Follow & Unfollow
|
||||||
return (<Button
|
return (<Button
|
||||||
size='sm'
|
size='sm'
|
||||||
|
@ -151,6 +166,9 @@ class ActionButton extends ImmutablePureComponent {
|
||||||
} else if (account.getIn(['relationship', 'blocking'])) {
|
} else if (account.getIn(['relationship', 'blocking'])) {
|
||||||
// Unblock
|
// Unblock
|
||||||
return <Button theme='danger' size='sm' text={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.handleBlock} />;
|
return <Button theme='danger' size='sm' text={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.handleBlock} />;
|
||||||
|
} else if (account.getIn(['relationship', 'muting'])) {
|
||||||
|
// Unmute
|
||||||
|
return <Button theme='danger' size='sm' text={intl.formatMessage(messages.unmute, { name: account.get('username') })} onClick={this.handleMute} />;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Edit profile
|
// Edit profile
|
||||||
|
|
Loading…
Reference in a new issue