summaryrefslogtreecommitdiffstats
path: root/webapp/components/user_settings
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-06 20:42:49 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-12-06 18:42:49 -0500
commit3ea49822b3dce879e7ca4dd878d40a17f82f528c (patch)
tree9edec6ce365c285e2c808aff86e4e1e01736c7a4 /webapp/components/user_settings
parente57cba15ea13bdd2eb7a23ba7c7853c6d9c3ef64 (diff)
downloadchat-3ea49822b3dce879e7ca4dd878d40a17f82f528c.tar.gz
chat-3ea49822b3dce879e7ca4dd878d40a17f82f528c.tar.bz2
chat-3ea49822b3dce879e7ca4dd878d40a17f82f528c.zip
PLT-4762 Prevent turn off of (at)mentions (webapp) (#4715)
Diffstat (limited to 'webapp/components/user_settings')
-rw-r--r--webapp/components/user_settings/user_settings_notifications.jsx68
1 files changed, 12 insertions, 56 deletions
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 {
</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') {