[MM-8404] Channel notification setting for disabling channel mentions (#MM-8404) (#2302)
* Channel notification setting for disabling channel mentions (#MM-8404) * Replaces raw string value by constants (#MM-8404) * Updates import according to redux update (#MM-8404)
This commit is contained in:
parent
91f9ea572b
commit
92469f2f21
3 changed files with 35 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ import {
|
|||
View,
|
||||
} from 'react-native';
|
||||
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {General, Users} from 'mattermost-redux/constants';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
|
|
@ -56,6 +56,7 @@ export default class ChannelInfo extends PureComponent {
|
|||
isFavorite: PropTypes.bool.isRequired,
|
||||
canManageUsers: PropTypes.bool.isRequired,
|
||||
canEditChannel: PropTypes.bool.isRequired,
|
||||
ignoreChannelMentions: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static contextTypes = {
|
||||
|
|
@ -68,6 +69,7 @@ export default class ChannelInfo extends PureComponent {
|
|||
this.state = {
|
||||
isFavorite: props.isFavorite,
|
||||
isMuted: props.isChannelMuted,
|
||||
ignoreChannelMentions: props.ignoreChannelMentions,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +93,12 @@ export default class ChannelInfo extends PureComponent {
|
|||
isMuted = nextProps.isChannelMuted;
|
||||
}
|
||||
|
||||
this.setState({isFavorite, isMuted});
|
||||
let ignoreChannelMentions = this.state.ignoreChannelMentions;
|
||||
if (ignoreChannelMentions !== nextProps.ignoreChannelMentions) {
|
||||
ignoreChannelMentions = nextProps.ignoreChannelMentions;
|
||||
}
|
||||
|
||||
this.setState({isFavorite, isMuted, ignoreChannelMentions});
|
||||
}
|
||||
|
||||
close = (redirect = true) => {
|
||||
|
|
@ -313,6 +320,18 @@ export default class ChannelInfo extends PureComponent {
|
|||
updateChannelNotifyProps(currentUserId, currentChannel.id, opts);
|
||||
};
|
||||
|
||||
handleIgnoreChannelMentions = () => {
|
||||
const {actions, currentChannel, currentUserId, ignoreChannelMentions} = this.props;
|
||||
const {updateChannelNotifyProps} = actions;
|
||||
|
||||
const opts = {
|
||||
ignore_channel_mentions: ignoreChannelMentions ? Users.IGNORE_CHANNEL_MENTIONS_OFF : Users.IGNORE_CHANNEL_MENTIONS_ON,
|
||||
};
|
||||
|
||||
this.setState({ignoreChannelMentions: !ignoreChannelMentions});
|
||||
updateChannelNotifyProps(currentUserId, currentChannel.id, opts);
|
||||
}
|
||||
|
||||
showPermalinkView = (postId) => {
|
||||
const {actions, navigator} = this.props;
|
||||
|
||||
|
|
@ -409,6 +428,16 @@ export default class ChannelInfo extends PureComponent {
|
|||
theme={theme}
|
||||
/>
|
||||
<View style={style.separator}/>
|
||||
<ChannelInfoRow
|
||||
action={this.handleIgnoreChannelMentions}
|
||||
defaultMessage='Ignore @channel, @here, @all'
|
||||
detail={this.state.ignoreChannelMentions}
|
||||
icon='at'
|
||||
textId={t('channel_notifications.ignoreChannelMentions.settings')}
|
||||
togglable={true}
|
||||
theme={theme}
|
||||
/>
|
||||
<View style={style.separator}/>
|
||||
<ChannelInfoRow
|
||||
action={this.goToPinnedPosts}
|
||||
defaultMessage='Pinned Posts'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
isCurrentChannelReadOnly,
|
||||
} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getCurrentUserId, getUser, getStatusForUserId, getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getUserIdFromChannelName, isChannelMuted, showDeleteOption, showManagementOptions} from 'mattermost-redux/utils/channel_utils';
|
||||
import {areChannelMentionsIgnored, getUserIdFromChannelName, isChannelMuted, showDeleteOption, showManagementOptions} from 'mattermost-redux/utils/channel_utils';
|
||||
import {isAdmin as checkIsAdmin, isChannelAdmin as checkIsChannelAdmin, isSystemAdmin as checkIsSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
|
|
@ -55,6 +55,7 @@ function mapStateToProps(state) {
|
|||
const isFavorite = favoriteChannels && favoriteChannels.indexOf(currentChannel.id) > -1;
|
||||
const roles = getCurrentUserRoles(state);
|
||||
const canManageUsers = currentChannel.hasOwnProperty('id') ? canManageChannelMembers(state) : false;
|
||||
const currentUser = getUser(state, currentUserId);
|
||||
|
||||
let status;
|
||||
if (currentChannel.type === General.DM_CHANNEL) {
|
||||
|
|
@ -79,6 +80,7 @@ function mapStateToProps(state) {
|
|||
currentChannelMemberCount,
|
||||
currentUserId,
|
||||
isChannelMuted: isChannelMuted(currentChannelMember),
|
||||
ignoreChannelMentions: areChannelMentionsIgnored(currentChannelMember.notify_props, currentUser.notify_props),
|
||||
isCurrent,
|
||||
isFavorite,
|
||||
status,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
"channel_modal.purpose": "Purpose",
|
||||
"channel_modal.purposeEx": "E.g.: \"A channel to file bugs and improvements\"",
|
||||
"channel_notifications.muteChannel.settings": "Mute channel",
|
||||
"channel_notifications.ignoreChannelMentions.settings": "Ignore @channel, @here, @all",
|
||||
"combined_system_message.added_to_channel.many_expanded": "{users} and {lastUser} were **added to the channel** by {actor}.",
|
||||
"combined_system_message.added_to_channel.one": "{firstUser} **added to the channel** by {actor}.",
|
||||
"combined_system_message.added_to_channel.one_you": "You were **added to the channel** by {actor}.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue