From 3ea49822b3dce879e7ca4dd878d40a17f82f528c Mon Sep 17 00:00:00 2001 From: enahum Date: Tue, 6 Dec 2016 20:42:49 -0300 Subject: PLT-4762 Prevent turn off of (at)mentions (webapp) (#4715) --- .../user_settings/user_settings_notifications.jsx | 68 ++++------------------ webapp/i18n/en.json | 1 - 2 files changed, 12 insertions(+), 57 deletions(-) (limited to 'webapp') diff --git a/webapp/components/user_settings/user_settings_notifications.jsx b/webapp/components/user_settings/user_settings_notifications.jsx index da7b9d757..2ee33c092 100644 --- a/webapp/components/user_settings/user_settings_notifications.jsx +++ b/webapp/components/user_settings/user_settings_notifications.jsx @@ -52,14 +52,13 @@ function getNotificationsStateFromStores() { } let usernameKey = false; - let mentionKey = false; let customKeys = ''; let firstNameKey = false; let channelKey = false; if (user.notify_props) { if (user.notify_props.mention_keys) { - var keys = user.notify_props.mention_keys.split(','); + const keys = user.notify_props.mention_keys.split(','); if (keys.indexOf(user.username) === -1) { usernameKey = false; @@ -68,13 +67,6 @@ function getNotificationsStateFromStores() { keys.splice(keys.indexOf(user.username), 1); } - if (keys.indexOf('@' + user.username) === -1) { - mentionKey = false; - } else { - mentionKey = true; - keys.splice(keys.indexOf('@' + user.username), 1); - } - customKeys = keys.join(','); } @@ -95,7 +87,6 @@ function getNotificationsStateFromStores() { pushStatus, desktopSound: sound, usernameKey, - mentionKey, customKeys, customKeysChecked: customKeys.length > 0, firstNameKey, @@ -117,7 +108,6 @@ export default class NotificationsTab extends React.Component { this.onListenerChange = this.onListenerChange.bind(this); this.handleEmailRadio = this.handleEmailRadio.bind(this); this.updateUsernameKey = this.updateUsernameKey.bind(this); - this.updateMentionKey = this.updateMentionKey.bind(this); this.updateFirstNameKey = this.updateFirstNameKey.bind(this); this.updateChannelKey = this.updateChannelKey.bind(this); this.updateCustomMentionKeys = this.updateCustomMentionKeys.bind(this); @@ -129,7 +119,7 @@ export default class NotificationsTab extends React.Component { } handleSubmit() { - var data = {}; + const data = {}; data.user_id = this.props.user.id; data.email = this.state.enableEmail; data.desktop_sound = this.state.desktopSound; @@ -139,15 +129,12 @@ export default class NotificationsTab extends React.Component { data.push_status = this.state.pushStatus; data.comments = this.state.notifyCommentsLevel; - var mentionKeys = []; + const mentionKeys = []; if (this.state.usernameKey) { mentionKeys.push(this.props.user.username); } - if (this.state.mentionKey) { - mentionKeys.push('@' + this.props.user.username); - } - var stringKeys = mentionKeys.join(','); + let stringKeys = mentionKeys.join(','); if (this.state.customKeys.length > 0 && this.state.customKeysChecked) { stringKeys += ',' + this.state.customKeys; } @@ -229,10 +216,6 @@ export default class NotificationsTab extends React.Component { this.setState({usernameKey: val}); } - updateMentionKey(val) { - this.setState({mentionKey: val}); - } - updateFirstNameKey(val) { this.setState({firstNameKey: val}); } @@ -242,10 +225,10 @@ export default class NotificationsTab extends React.Component { } updateCustomMentionKeys() { - var checked = this.refs.customcheck.checked; + const checked = this.refs.customcheck.checked; if (checked) { - var text = this.refs.custommentions.value; + const text = this.refs.custommentions.value; // remove all spaces and split string into individual keys this.setState({customKeys: text.replace(/ /g, ''), customKeysChecked: true}); @@ -524,8 +507,8 @@ export default class NotificationsTab extends React.Component { const serverError = this.state.serverError; const user = this.props.user; - var keysSection; - var handleUpdateKeysSection; + let keysSection; + let handleUpdateKeysSection; if (this.props.activeSection === 'keys') { const inputs = []; @@ -579,30 +562,6 @@ export default class NotificationsTab extends React.Component { ); - const handleUpdateMentionKey = (e) => { - this.updateMentionKey(e.target.checked); - }; - inputs.push( -
-
- -
-
- ); - const handleUpdateChannelKey = (e) => { this.updateChannelKey(e.target.checked); }; @@ -667,9 +626,6 @@ export default class NotificationsTab extends React.Component { if (this.state.usernameKey) { keys.push(user.username); } - if (this.state.mentionKey) { - keys.push('@' + user.username); - } if (this.state.channelKey) { keys.push('@channel'); @@ -680,7 +636,7 @@ export default class NotificationsTab extends React.Component { } let describe = ''; - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { if (keys[i] !== '') { describe += '"' + keys[i] + '", '; } @@ -710,10 +666,10 @@ export default class NotificationsTab extends React.Component { ); } - var commentsSection; - var handleUpdateCommentsSection; + let commentsSection; + let handleUpdateCommentsSection; if (this.props.activeSection === 'comments') { - var commentsActive = [false, false, false]; + const commentsActive = [false, false, false]; if (this.state.notifyCommentsLevel === 'never') { commentsActive[2] = true; } else if (this.state.notifyCommentsLevel === 'root') { diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index ed519a8b2..baad18f95 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -2046,7 +2046,6 @@ "user.settings.notifications.sounds_info": "Notification sounds are available on IE11, Edge, Safari, Chrome and Mattermost Desktop Apps.", "user.settings.notifications.teamWide": "Team-wide mentions \"@all\"", "user.settings.notifications.title": "Notification Settings", - "user.settings.notifications.usernameMention": "Your username mentioned \"@{username}\"", "user.settings.notifications.wordsTrigger": "Words that trigger mentions", "user.settings.push_notification.allActivity": "For all activity", "user.settings.push_notification.allActivityAway": "For all activity when away or offline", -- cgit v1.2.3-1-g7c22