PLT-4762 Prevent turn off of (at)mentions (webapp) (#4715)

This commit is contained in:
enahum
2016-12-06 20:42:49 -03:00
committed by Joram Wilander
parent e57cba15ea
commit 3ea49822b3
2 changed files with 12 additions and 57 deletions

View File

@@ -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 {
</div>
);
const handleUpdateMentionKey = (e) => {
this.updateMentionKey(e.target.checked);
};
inputs.push(
<div key='userNotificationMentionOption'>
<div className='checkbox'>
<label>
<input
type='checkbox'
checked={this.state.mentionKey}
onChange={handleUpdateMentionKey}
/>
<FormattedMessage
id='user.settings.notifications.usernameMention'
defaultMessage='Your username mentioned "@{username}"'
values={{
username: user.username
}}
/>
</label>
</div>
</div>
);
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') {

View File

@@ -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",