summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authoratp <pruthvip15@gmail.com>2017-08-21 19:30:40 +0530
committerHarrison Healey <harrisonmhealey@gmail.com>2017-08-21 10:00:40 -0400
commit2986c384690951b2e87c016efaa6f447d844e6b2 (patch)
tree7a55aa81ef687fb0a942d09053ebe0e4fb3886f7 /webapp/components
parent22efdbe6fb897ea1b4b2cf52c66eb3037474fcf5 (diff)
downloadchat-2986c384690951b2e87c016efaa6f447d844e6b2.tar.gz
chat-2986c384690951b2e87c016efaa6f447d844e6b2.tar.bz2
chat-2986c384690951b2e87c016efaa6f447d844e6b2.zip
PLT-7256: Fix email rate selection when batching is disabled (#7202)
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/user_settings/email_notification_setting.jsx53
1 files changed, 37 insertions, 16 deletions
diff --git a/webapp/components/user_settings/email_notification_setting.jsx b/webapp/components/user_settings/email_notification_setting.jsx
index 5abdc3384..bbde40fa1 100644
--- a/webapp/components/user_settings/email_notification_setting.jsx
+++ b/webapp/components/user_settings/email_notification_setting.jsx
@@ -31,17 +31,9 @@ export default class EmailNotificationSetting extends React.Component {
this.expand = this.expand.bind(this);
this.collapse = this.collapse.bind(this);
- if (global.mm_config.EnableEmailBatching === 'true') {
- // when email batching is enabled, the default interval is 15 minutes
- this.state = {
- emailInterval: PreferenceStore.getInt(Preferences.CATEGORY_NOTIFICATIONS, Preferences.EMAIL_INTERVAL, Preferences.INTERVAL_FIFTEEN_MINUTES)
- };
- } else {
- // otherwise, the default interval is immediately
- this.state = {
- emailInterval: PreferenceStore.getInt(Preferences.CATEGORY_NOTIFICATIONS, Preferences.EMAIL_INTERVAL, Preferences.INTERVAL_IMMEDIATE)
- };
- }
+ this.state = {
+ emailInterval: EmailNotificationSetting.getEmailInterval(props)
+ };
}
handleChange(enableEmail, emailInterval) {
@@ -156,7 +148,7 @@ export default class EmailNotificationSetting extends React.Component {
id='emailNotificationMinutes'
type='radio'
name='emailNotifications'
- checked={this.props.enableEmail && this.state.emailInterval === Preferences.INTERVAL_FIFTEEN_MINUTES}
+ checked={this.state.emailInterval === Preferences.INTERVAL_FIFTEEN_MINUTES}
onChange={this.handleChange.bind(this, 'true', Preferences.INTERVAL_FIFTEEN_MINUTES)}
/>
<FormattedMessage
@@ -172,7 +164,7 @@ export default class EmailNotificationSetting extends React.Component {
id='emailNotificationHour'
type='radio'
name='emailNotifications'
- checked={this.props.enableEmail && this.state.emailInterval === Preferences.INTERVAL_HOUR}
+ checked={this.state.emailInterval === Preferences.INTERVAL_HOUR}
onChange={this.handleChange.bind(this, 'true', Preferences.INTERVAL_HOUR)}
/>
<FormattedMessage
@@ -209,7 +201,7 @@ export default class EmailNotificationSetting extends React.Component {
id='emailNotificationImmediately'
type='radio'
name='emailNotifications'
- checked={this.props.enableEmail && this.state.emailInterval === Preferences.INTERVAL_IMMEDIATE}
+ checked={this.state.emailInterval === Preferences.INTERVAL_IMMEDIATE}
onChange={this.handleChange.bind(this, 'true', Preferences.INTERVAL_IMMEDIATE)}
/>
<FormattedMessage
@@ -225,8 +217,8 @@ export default class EmailNotificationSetting extends React.Component {
id='emailNotificationNever'
type='radio'
name='emailNotifications'
- checked={!this.props.enableEmail}
- onChange={this.handleChange.bind(this, 'false', Preferences.INTERVAL_IMMEDIATE)}
+ checked={this.state.emailInterval === Preferences.INTERVAL_NEVER}
+ onChange={this.handleChange.bind(this, 'false', Preferences.INTERVAL_NEVER)}
/>
<FormattedMessage
id='user.settings.notifications.email.never'
@@ -254,4 +246,33 @@ export default class EmailNotificationSetting extends React.Component {
/>
);
}
+
+ static getEmailInterval(props) {
+ const validValuesWithEmailBatching = [Preferences.INTERVAL_IMMEDIATE, Preferences.INTERVAL_FIFTEEN_MINUTES, Preferences.INTERVAL_HOUR];
+ const validValuesWithoutEmailBatching = [Preferences.INTERVAL_IMMEDIATE];
+
+ let emailInterval;
+
+ if (global.mm_config.EnableEmailBatching === 'true') {
+ // when email batching is enabled, the default interval is 15 minutes
+ emailInterval = PreferenceStore.getInt(Preferences.CATEGORY_NOTIFICATIONS, Preferences.EMAIL_INTERVAL, Preferences.INTERVAL_FIFTEEN_MINUTES);
+
+ if (validValuesWithEmailBatching.indexOf(emailInterval) === -1) {
+ emailInterval = Preferences.INTERVAL_FIFTEEN_MINUTES;
+ }
+ } else {
+ // otherwise, the default interval is immediately
+ emailInterval = PreferenceStore.getInt(Preferences.CATEGORY_NOTIFICATIONS, Preferences.EMAIL_INTERVAL, Preferences.INTERVAL_IMMEDIATE);
+
+ if (validValuesWithoutEmailBatching.indexOf(emailInterval) === -1) {
+ emailInterval = Preferences.INTERVAL_IMMEDIATE;
+ }
+ }
+
+ if (!props.enableEmail) {
+ emailInterval = Preferences.INTERVAL_NEVER;
+ }
+
+ return emailInterval;
+ }
}