Skip to content

Commit

Permalink
Merge pull request #25618 from Expensify/chirag-hidden-notification
Browse files Browse the repository at this point in the history
Return early for hidden notification preference
  • Loading branch information
srikarparsi authored Aug 25, 2023
2 parents a906a7c + 74da686 commit fd407e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ const CONST = {
MUTE: 'mute',
DAILY: 'daily',
ALWAYS: 'always',
HIDDEN: 'hidden',
},
// Options for which room members can post
WRITE_CAPABILITIES: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,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;
}
Expand Down
19 changes: 12 additions & 7 deletions src/pages/settings/Report/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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}`);
Expand All @@ -79,12 +82,14 @@ function ReportSettingsPage(props) {
onBackButtonPress={() => Navigation.goBack(ROUTES.getReportDetailsRoute(report.reportID))}
/>
<ScrollView style={[styles.flex1]}>
<MenuItemWithTopDescription
shouldShowRightIcon
title={notificationPreference}
description={translate('notificationPreferencesPage.label')}
onPress={() => Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))}
/>
{report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && (
<MenuItemWithTopDescription
shouldShowRightIcon
title={notificationPreference}
description={translate('notificationPreferencesPage.label')}
onPress={() => Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))}
/>
)}
{shouldShowRoomName && (
<OfflineWithFeedback
pendingAction={lodashGet(report, 'pendingFields.reportName', null)}
Expand Down

0 comments on commit fd407e2

Please sign in to comment.