From c4d4009fadc8609d7f63c45b1b7d20783bc71da4 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 14 Mar 2019 01:57:49 +0800 Subject: [PATCH] Fix default behavior when enabling/disabling email batching (#2642) --- .../notification_settings_email/index.js | 2 +- .../notification_settings_email_base.js | 10 +++- package-lock.json | 55 +++++++++++++------ package.json | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/app/screens/settings/notification_settings_email/index.js b/app/screens/settings/notification_settings_email/index.js index 6010a1073..bb32301c4 100644 --- a/app/screens/settings/notification_settings_email/index.js +++ b/app/screens/settings/notification_settings_email/index.js @@ -25,7 +25,7 @@ function mapStateToProps(state) { state, Preferences.CATEGORY_NOTIFICATIONS, Preferences.EMAIL_INTERVAL, - Preferences.INTERVAL_IMMEDIATE.toString(), + Preferences.INTERVAL_NOT_SET.toString(), ); return { diff --git a/app/screens/settings/notification_settings_email/notification_settings_email_base.js b/app/screens/settings/notification_settings_email/notification_settings_email_base.js index 7b90c6fa4..021d1edf6 100644 --- a/app/screens/settings/notification_settings_email/notification_settings_email_base.js +++ b/app/screens/settings/notification_settings_email/notification_settings_email_base.js @@ -30,15 +30,18 @@ export default class NotificationSettingsEmailBase extends PureComponent { super(props); const { + currentUser, emailInterval, enableEmailBatching, navigator, sendEmailNotifications, } = props; + const notifyProps = getNotificationProps(currentUser); + this.state = { emailInterval, - newInterval: this.computeEmailInterval(sendEmailNotifications, enableEmailBatching, emailInterval), + newInterval: this.computeEmailInterval(notifyProps?.email === 'true' && sendEmailNotifications, enableEmailBatching, emailInterval), showEmailNotificationsModal: false, }; @@ -51,6 +54,7 @@ export default class NotificationSettingsEmailBase extends PureComponent { } const { + currentUser, sendEmailNotifications, enableEmailBatching, emailInterval, @@ -61,9 +65,11 @@ export default class NotificationSettingsEmailBase extends PureComponent { this.props.enableEmailBatching !== enableEmailBatching || this.props.emailInterval !== emailInterval ) { + const notifyProps = getNotificationProps(currentUser); + this.setState({ emailInterval, - newInterval: this.computeEmailInterval(sendEmailNotifications, enableEmailBatching, emailInterval), + newInterval: this.computeEmailInterval(notifyProps?.email === 'true' && sendEmailNotifications, enableEmailBatching, emailInterval), }); } } diff --git a/package-lock.json b/package-lock.json index 36a8bf256..1803a8fcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2688,6 +2688,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -2732,7 +2733,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "dev": true, + "optional": true }, "is-glob": { "version": "4.0.0", @@ -4359,7 +4361,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -4377,11 +4380,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4394,15 +4399,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4505,7 +4513,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4515,6 +4524,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4527,17 +4537,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4554,6 +4567,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4626,7 +4640,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4636,6 +4651,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4711,7 +4727,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4741,6 +4758,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4758,6 +4776,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4796,11 +4815,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -9238,8 +9259,8 @@ "integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==" }, "mattermost-redux": { - "version": "github:mattermost/mattermost-redux#b2312c0baa4111cf373843391069b49ef1794299", - "from": "github:mattermost/mattermost-redux#b2312c0baa4111cf373843391069b49ef1794299", + "version": "github:mattermost/mattermost-redux#8944a1fa67bb11d33874c234b7d83962c87d0aa6", + "from": "github:mattermost/mattermost-redux#8944a1fa67bb11d33874c234b7d83962c87d0aa6", "requires": { "deep-equal": "1.0.1", "eslint-plugin-header": "2.0.0", @@ -12338,7 +12359,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "dev": true, + "optional": true }, "braces": { "version": "2.3.2", @@ -12624,7 +12646,8 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true }, "micromatch": { "version": "3.1.10", diff --git a/package.json b/package.json index 6c961de30..cb6617502 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "intl": "1.2.5", "jail-monkey": "2.0.0", "jsc-android": "236355.1.1", - "mattermost-redux": "github:mattermost/mattermost-redux#b2312c0baa4111cf373843391069b49ef1794299", + "mattermost-redux": "github:mattermost/mattermost-redux#8944a1fa67bb11d33874c234b7d83962c87d0aa6", "mime-db": "1.38.0", "moment-timezone": "0.5.23", "prop-types": "15.7.2",