PLT-7256: Fix email rate selection when batching is disabled (#7202)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
22efdbe6fb
Коммит
2986c38469
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ export const Preferences = {
|
||||
EMAIL_INTERVAL: 'email_interval',
|
||||
INTERVAL_IMMEDIATE: 30, // "immediate" is a 30 second interval
|
||||
INTERVAL_FIFTEEN_MINUTES: 15 * 60,
|
||||
INTERVAL_HOUR: 60 * 60
|
||||
INTERVAL_HOUR: 60 * 60,
|
||||
INTERVAL_NEVER: 0
|
||||
};
|
||||
|
||||
export const ActionTypes = keyMirror({
|
||||
|
||||
Ссылка в новой задаче
Block a user