From 20665cacdb5ce90a5c23d9d06e4415f067904a05 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 13:05:18 -0700 Subject: [PATCH 1/9] new hidden notification preference const --- src/CONST.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.js b/src/CONST.js index e8c95b83f57e..b576d1b54d00 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -577,6 +577,7 @@ const CONST = { MUTE: 'mute', DAILY: 'daily', ALWAYS: 'always', + HIDDEN: 'hidden', }, // Options for which room members can post WRITE_CAPABILITIES: { From 0c70a32e7951a519b5552ba72b9cc52a51e4828e Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 13:05:45 -0700 Subject: [PATCH 2/9] return early for hidden notification preference --- src/components/LHNOptionsList/OptionRowLHN.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index a3fbb5e41378..a01f1ab8322e 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -68,8 +68,8 @@ function OptionRowLHN(props) { return null; } - const isMuted = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE; - if (isMuted && !props.isFocused && !optionItem.isPinned) { + const isHidden = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + if (isHidden && !props.isFocused && !optionItem.isPinned) { return null; } From 951afa2f27b8864a76178b82b910a7dd9f962685 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 16:10:42 -0700 Subject: [PATCH 3/9] adding hidden translation --- src/languages/en.js | 1 + src/languages/es.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.js b/src/languages/en.js index b4712c676446..19c04614fafd 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -446,6 +446,7 @@ export default { always: 'Immediately', daily: 'Daily', mute: 'Mute', + hidden: 'Hidden', }, }, loginField: { diff --git a/src/languages/es.js b/src/languages/es.js index c3c950b04a8c..8e37669c30f8 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -445,6 +445,7 @@ export default { always: 'Inmediatamente', daily: 'Cada día', mute: 'Nunca', + hidden: 'Oculto', }, }, loginField: { From cb7f190d774184d7a77723705920969921bbb0b4 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 16:10:55 -0700 Subject: [PATCH 4/9] excluding hidden from selectable choices --- .../Report/NotificationPreferencePage.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 9765cf1ae0b4..2b357669280d 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -15,6 +15,7 @@ import * as Report from '../../../libs/actions/Report'; import * as ReportUtils from '../../../libs/ReportUtils'; import * as Expensicons from '../../../components/Icon/Expensicons'; import themeColors from '../../../styles/themes/default'; +import CONST from '../../../CONST'; const propTypes = { ...withLocalizePropTypes, @@ -26,17 +27,20 @@ const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report) || ReportUtils.isArchivedRoom(props.report); - const notificationPreferenceOptions = _.map(props.translate('notificationPreferencesPage.notificationPreferences'), (preference, key) => ({ - value: key, - text: preference, - keyForList: key, + const notificationPreferenceOptions = _.chain(props.translate('notificationPreferencesPage.notificationPreferences')) + .reject(preference => preference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) + .map((preference, key) => ({ + value: key, + text: preference, + keyForList: key, - // Include the green checkmark icon to indicate the currently selected value - customIcon: key === props.report.notificationPreference ? greenCheckmark : null, + // Include the green checkmark icon to indicate the currently selected value + customIcon: key === props.report.notificationPreference ? greenCheckmark : null, - // This property will make the currently selected value have bold text - boldStyle: key === props.report.notificationPreference, - })); + // This property will make the currently selected value have bold text + boldStyle: key === props.report.notificationPreference, + })) + .value(); return ( From 9728ec8a66b08c97d44a487d85b71ef5a785b49d Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 16:32:41 -0700 Subject: [PATCH 5/9] receive ping notification only for preference always --- src/libs/actions/Report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 3bc4ea966b23..0198a9bb57ea 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1545,9 +1545,9 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = return false; } - // We don't want to send a local notification if the user preference is daily or mute + // We don't want to send a local notification if the user preference is daily, mute or hidden. const notificationPreference = lodashGet(allReports, [reportID, 'notificationPreference'], CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS); - if (notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE || notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.DAILY) { + if (notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS) { Log.info(`${tag} No notification because user preference is to be notified: ${notificationPreference}`); return false; } From 7826ae6f65bb0852376ed081ae47ce0b9390de1d Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Mon, 21 Aug 2023 16:38:51 -0700 Subject: [PATCH 6/9] lint fix --- src/pages/settings/Report/NotificationPreferencePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 2b357669280d..fd50b08282fe 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -28,7 +28,7 @@ const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report) || ReportUtils.isArchivedRoom(props.report); const notificationPreferenceOptions = _.chain(props.translate('notificationPreferencesPage.notificationPreferences')) - .reject(preference => preference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) + .reject((preference) => preference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) .map((preference, key) => ({ value: key, text: preference, From 552a4f4e60937d67c497aa0ee634f6fd3a9edf5c Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Wed, 23 Aug 2023 13:56:57 -0700 Subject: [PATCH 7/9] show notification only for non hidden notification preference --- src/pages/settings/Report/ReportSettingsPage.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/settings/Report/ReportSettingsPage.js b/src/pages/settings/Report/ReportSettingsPage.js index b21c4b971dca..f85d3831124a 100644 --- a/src/pages/settings/Report/ReportSettingsPage.js +++ b/src/pages/settings/Report/ReportSettingsPage.js @@ -79,12 +79,14 @@ function ReportSettingsPage(props) { onBackButtonPress={() => Navigation.goBack(ROUTES.getReportDetailsRoute(report.reportID))} /> - Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))} - /> + {report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && + Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))} + /> + } {shouldShowRoomName && ( Date: Wed, 23 Aug 2023 14:10:09 -0700 Subject: [PATCH 8/9] removing preference hidden from languages since we do not display it anymore --- src/languages/en.js | 1 - src/languages/es.js | 1 - .../Report/NotificationPreferencePage.js | 21 ++++++++----------- .../settings/Report/ReportSettingsPage.js | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 468731f05ac6..84b0561b3c38 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -451,7 +451,6 @@ export default { always: 'Immediately', daily: 'Daily', mute: 'Mute', - hidden: 'Hidden', }, }, loginField: { diff --git a/src/languages/es.js b/src/languages/es.js index 7280023c7a49..eb2a667bdb38 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -450,7 +450,6 @@ export default { always: 'Inmediatamente', daily: 'Cada día', mute: 'Nunca', - hidden: 'Oculto', }, }, loginField: { diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index fd50b08282fe..aed42f419df6 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -27,20 +27,17 @@ const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report) || ReportUtils.isArchivedRoom(props.report); - const notificationPreferenceOptions = _.chain(props.translate('notificationPreferencesPage.notificationPreferences')) - .reject((preference) => preference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) - .map((preference, key) => ({ - value: key, - text: preference, - keyForList: key, + const notificationPreferenceOptions = _.map(props.translate('notificationPreferencesPage.notificationPreferences'), (preference, key) => ({ + value: key, + text: preference, + keyForList: key, - // Include the green checkmark icon to indicate the currently selected value - customIcon: key === props.report.notificationPreference ? greenCheckmark : null, + // Include the green checkmark icon to indicate the currently selected value + customIcon: key === props.report.notificationPreference ? greenCheckmark : null, - // This property will make the currently selected value have bold text - boldStyle: key === props.report.notificationPreference, - })) - .value(); + // This property will make the currently selected value have bold text + boldStyle: key === props.report.notificationPreference, + })); return ( diff --git a/src/pages/settings/Report/ReportSettingsPage.js b/src/pages/settings/Report/ReportSettingsPage.js index f85d3831124a..5a1e770f5176 100644 --- a/src/pages/settings/Report/ReportSettingsPage.js +++ b/src/pages/settings/Report/ReportSettingsPage.js @@ -65,7 +65,7 @@ function ReportSettingsPage(props) { const shouldDisableSettings = _.isEmpty(report) || ReportUtils.shouldDisableSettings(report) || ReportUtils.isArchivedRoom(report); const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report); - const notificationPreference = translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`); + const notificationPreference = report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN ? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`) : ''; const writeCapability = ReportUtils.isAdminRoom(report) ? CONST.REPORT.WRITE_CAPABILITIES.ADMINS : report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL; const writeCapabilityText = translate(`writeCapabilityPage.writeCapability.${writeCapability}`); From 74da68653df32c14d81545a920e32bd7b206280e Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Wed, 23 Aug 2023 14:15:27 -0700 Subject: [PATCH 9/9] lint and style fix --- src/pages/settings/Report/NotificationPreferencePage.js | 1 - src/pages/settings/Report/ReportSettingsPage.js | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index aed42f419df6..9765cf1ae0b4 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -15,7 +15,6 @@ import * as Report from '../../../libs/actions/Report'; import * as ReportUtils from '../../../libs/ReportUtils'; import * as Expensicons from '../../../components/Icon/Expensicons'; import themeColors from '../../../styles/themes/default'; -import CONST from '../../../CONST'; const propTypes = { ...withLocalizePropTypes, diff --git a/src/pages/settings/Report/ReportSettingsPage.js b/src/pages/settings/Report/ReportSettingsPage.js index 5a1e770f5176..c2bd69028a44 100644 --- a/src/pages/settings/Report/ReportSettingsPage.js +++ b/src/pages/settings/Report/ReportSettingsPage.js @@ -65,7 +65,10 @@ function ReportSettingsPage(props) { const shouldDisableSettings = _.isEmpty(report) || ReportUtils.shouldDisableSettings(report) || ReportUtils.isArchivedRoom(report); const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report); - const notificationPreference = report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN ? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`) : ''; + const notificationPreference = + report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN + ? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`) + : ''; const writeCapability = ReportUtils.isAdminRoom(report) ? CONST.REPORT.WRITE_CAPABILITIES.ADMINS : report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL; const writeCapabilityText = translate(`writeCapabilityPage.writeCapability.${writeCapability}`); @@ -79,14 +82,14 @@ function ReportSettingsPage(props) { onBackButtonPress={() => Navigation.goBack(ROUTES.getReportDetailsRoute(report.reportID))} /> - {report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && + {report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && ( Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))} /> - } + )} {shouldShowRoomName && (