diff --git a/app/screens/channel_notification_preference/channel_notification_preference.android.js b/app/screens/channel_notification_preference/channel_notification_preference.android.js
index b5407a2b4..4e9d69b1a 100644
--- a/app/screens/channel_notification_preference/channel_notification_preference.android.js
+++ b/app/screens/channel_notification_preference/channel_notification_preference.android.js
@@ -23,7 +23,7 @@ export default class ChannelNotificationPreferenceAndroid extends ChannelNotific
label: intl.formatMessage({
id: element.id,
defaultMessage: element.defaultMessage,
- }),
+ }, element.labelValues),
value: element.value,
checked: element.checked,
};
diff --git a/app/screens/channel_notification_preference/channel_notification_preference.ios.js b/app/screens/channel_notification_preference/channel_notification_preference.ios.js
index 8f8ffb1f3..4436affb0 100644
--- a/app/screens/channel_notification_preference/channel_notification_preference.ios.js
+++ b/app/screens/channel_notification_preference/channel_notification_preference.ios.js
@@ -46,6 +46,7 @@ export default class ChannelNotificationPreferenceIos extends ChannelNotificatio
)}
action={this.handlePress}
diff --git a/app/screens/channel_notification_preference/channel_notification_preference.test.js b/app/screens/channel_notification_preference/channel_notification_preference.test.js
index dc57735ee..476696b79 100644
--- a/app/screens/channel_notification_preference/channel_notification_preference.test.js
+++ b/app/screens/channel_notification_preference/channel_notification_preference.test.js
@@ -6,7 +6,7 @@ import {ViewTypes} from '@constants';
import Preferences from '@mm-redux/constants/preferences';
import SectionItem from '@screens/settings/section_item';
-import {shallowWithIntl} from 'test/intl-test-helper';
+import {shallowWithIntlMessages} from 'test/intl-test-helper';
import ChannelNotificationPreference from './channel_notification_preference';
function makeProps(pushNotificationLevel) {
@@ -15,6 +15,9 @@ function makeProps(pushNotificationLevel) {
updateChannelNotifyProps: jest.fn(),
},
channelId: 'channel_id',
+ globalNotifyProps: {
+ push: 'mention',
+ },
userId: 'user_id',
notifyProps: {
push: pushNotificationLevel,
@@ -25,7 +28,7 @@ function makeProps(pushNotificationLevel) {
}
function checkNotificationSelected(pushNotificationLevel, trueIdx) {
- const wrapper = shallowWithIntl(
+ const wrapper = shallowWithIntlMessages(
,
@@ -52,7 +55,7 @@ describe('ChannelNotificationPreference', () => {
test('should save on click', () => {
const props = makeProps('default');
- const wrapper = shallowWithIntl(
+ const wrapper = shallowWithIntlMessages(
,
);
diff --git a/app/screens/channel_notification_preference/channel_notification_preference_base.js b/app/screens/channel_notification_preference/channel_notification_preference_base.js
index f36c25c22..f13bf148b 100644
--- a/app/screens/channel_notification_preference/channel_notification_preference_base.js
+++ b/app/screens/channel_notification_preference/channel_notification_preference_base.js
@@ -16,6 +16,7 @@ export default class ChannelNotificationPreferenceBase extends PureComponent {
updateChannelNotifyProps: PropTypes.func.isRequired,
}),
channelId: PropTypes.string.isRequired,
+ globalNotifyProps: PropTypes.object.isRequired,
isLandscape: PropTypes.bool.isRequired,
notifyProps: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
@@ -35,25 +36,33 @@ export default class ChannelNotificationPreferenceBase extends PureComponent {
}
getItems = () => {
+ const {formatMessage} = this.context.intl;
+ const {globalNotifyProps} = this.props;
const {notificationLevel} = this.state;
+ const defaultNotificationLevel = formatMessage({id: `channel_header.notificationPreference.${globalNotifyProps?.push.toLowerCase()}`});
+
return [{
id: t('channel_notifications.preference.global_default'),
- defaultMessage: 'Global default (Mentions)',
+ defaultMessage: 'Global default ({notifyLevel})',
+ labelValues: {notifyLevel: defaultNotificationLevel},
value: ViewTypes.NotificationLevels.DEFAULT,
checked: notificationLevel === ViewTypes.NotificationLevels.DEFAULT,
}, {
id: t('channel_notifications.preference.all_activity'),
defaultMessage: 'For all activity',
+ labelValues: undefined,
value: ViewTypes.NotificationLevels.ALL,
checked: notificationLevel === ViewTypes.NotificationLevels.ALL,
}, {
id: t('channel_notifications.preference.only_mentions'),
defaultMessage: 'Only mentions and direct messages',
+ labelValues: undefined,
value: ViewTypes.NotificationLevels.MENTION,
checked: notificationLevel === ViewTypes.NotificationLevels.MENTION,
}, {
id: t('channel_notifications.preference.never'),
defaultMessage: 'Never',
+ labelValues: undefined,
value: ViewTypes.NotificationLevels.NONE,
checked: notificationLevel === ViewTypes.NotificationLevels.NONE,
}];
diff --git a/app/screens/channel_notification_preference/index.js b/app/screens/channel_notification_preference/index.js
index d8ac34547..0f987e59e 100644
--- a/app/screens/channel_notification_preference/index.js
+++ b/app/screens/channel_notification_preference/index.js
@@ -4,16 +4,17 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {updateChannelNotifyProps} from '@mm-redux/actions/channels';
+import {getCurrentUser} from '@mm-redux/selectors/entities/users';
import {getTheme} from '@mm-redux/selectors/entities/preferences';
import {isLandscape} from 'app/selectors/device';
import ChannelNotificationPreference from './channel_notification_preference';
function mapStateToProps(state) {
- const theme = getTheme(state);
return {
- theme,
+ globalNotifyProps: getCurrentUser(state)?.notify_props,
isLandscape: isLandscape(state),
+ theme: getTheme(state),
};
}
diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json
index 691c18be6..b0cc57172 100644
--- a/assets/base/i18n/en.json
+++ b/assets/base/i18n/en.json
@@ -41,7 +41,7 @@
"channel_notifications.ignoreChannelMentions.settings": "Ignore @channel, @here, @all",
"channel_notifications.muteChannel.settings": "Mute channel",
"channel_notifications.preference.all_activity": "For all activity",
- "channel_notifications.preference.global_default": "Global default (Mentions)",
+ "channel_notifications.preference.global_default": "Global default ({notifyLevel})",
"channel_notifications.preference.header": "Send Notifications",
"channel_notifications.preference.never": "Never",
"channel_notifications.preference.only_mentions": "Only mentions and direct messages",
diff --git a/test/intl-test-helper.js b/test/intl-test-helper.js
index cd575ba69..c8d464a24 100644
--- a/test/intl-test-helper.js
+++ b/test/intl-test-helper.js
@@ -5,6 +5,8 @@ import React from 'react';
import {IntlProvider, intlShape} from 'react-intl';
import {mount, shallow} from 'enzyme';
+import {getTranslations} from '@i18n';
+
const intlProvider = new IntlProvider({locale: 'en'}, {});
const {intl} = intlProvider.getChildContext();
@@ -14,6 +16,15 @@ export function shallowWithIntl(node, {context} = {}) {
});
}
+export function shallowWithIntlMessages(node, {context} = {}) {
+ const provider = new IntlProvider({locale: 'en', messages: getTranslations('en')}, {});
+ const {intl: intlWithMessages} = provider.getChildContext();
+
+ return shallow(React.cloneElement(node, {intl: intlWithMessages}), {
+ context: Object.assign({}, context, {intl: intlWithMessages}),
+ });
+}
+
export function mountWithIntl(node, {context, childContextTypes} = {}) {
return mount(React.cloneElement(node, {intl}), {
context: Object.assign({}, context, {intl}),