From 92469f2f216a2e6105d5d4f607463f787fd8bc9e Mon Sep 17 00:00:00 2001 From: Tsilavina Razafinirina Date: Thu, 6 Dec 2018 20:08:28 +0300 Subject: [PATCH] [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) --- app/screens/channel_info/channel_info.js | 33 ++++++++++++++++++++++-- app/screens/channel_info/index.js | 4 ++- assets/base/i18n/en.json | 1 + 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index e94933882..613e2d9fe 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -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} /> + + -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, diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 31a76ab90..ab21ab0e2 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -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}.",