Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notification preference by defaulting to hidden #48887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/hooks/useResponsiveLayout/__mocks__/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function useResponsiveLayout() {
return {
shouldUseNarrowLayout: false,
isSmallScreenWidth: false,
isInNarrowPaneModal: false,
isExtraSmallScreenHeight: false,
isExtraSmallScreenWidth: false,
isMediumScreenWidth: false,
onboardingIsMediumOrLargerScreenWidth: true,
isLargeScreenWidth: true,
isSmallScreen: false,
};
}
13 changes: 13 additions & 0 deletions src/hooks/useResponsiveLayout/__mocks__/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function useResponsiveLayout() {
return {
shouldUseNarrowLayout: false,
isSmallScreenWidth: false,
isInNarrowPaneModal: false,
isExtraSmallScreenHeight: false,
isExtraSmallScreenWidth: false,
isMediumScreenWidth: false,
onboardingIsMediumOrLargerScreenWidth: true,
isLargeScreenWidth: true,
isSmallScreen: false,
};
}
7 changes: 5 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,11 @@ function getDefaultNotificationPreferenceForReport(report: OnyxEntry<Report>): V
/**
* Get the notification preference given a report
*/
function getReportNotificationPreference(report: OnyxEntry<Report>): ValueOf<typeof CONST.REPORT.NOTIFICATION_PREFERENCE> {
return report?.participants?.[currentUserAccountID ?? -1]?.notificationPreference ?? getDefaultNotificationPreferenceForReport(report);
function getReportNotificationPreference(report: OnyxEntry<Report>, shouldDefaltToHidden = true): ValueOf<typeof CONST.REPORT.NOTIFICATION_PREFERENCE> {
if (!shouldDefaltToHidden) {
return report?.participants?.[currentUserAccountID ?? -1]?.notificationPreference ?? getDefaultNotificationPreferenceForReport(report);
}
return report?.participants?.[currentUserAccountID ?? -1]?.notificationPreference ?? CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
}

const CONCIERGE_ACCOUNT_ID_STRING = CONST.ACCOUNT_ID.CONCIERGE.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
value: {[report.parentReportActionID]: {childReportNotificationPreference: ReportUtils.getReportNotificationPreference(report)}},
value: {[report.parentReportActionID]: {childReportNotificationPreference: ReportUtils.getReportNotificationPreference(report, false)}},
});
}

Expand Down
8 changes: 6 additions & 2 deletions tests/perf-test/SidebarLinks.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ describe('SidebarLinks', () => {

// Initialize the network key for OfflineWithFeedback
Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false});
Onyx.clear().then(waitForBatchedUpdates);
TestHelper.signInWithTestUser(1, 'email1@test.com', undefined, undefined, 'One').then(waitForBatchedUpdates);
});

afterEach(() => {
Onyx.clear();
});

test('[SidebarLinks] should render Sidebar with 500 reports stored', async () => {
Expand Down Expand Up @@ -87,7 +91,7 @@ describe('SidebarLinks', () => {
* Query for display names of participants [1, 2].
* This will ensure that the sidebar renders a list of items.
*/
await screen.findAllByText('One, Two');
await screen.findAllByText('Email Two');
};

await waitForBatchedUpdates();
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/PaginationTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ async function signInAndGetApp(): Promise<void> {
reportID: REPORT_ID,
reportName: CONST.REPORT.DEFAULT_REPORT_NAME,
lastMessageText: 'Test',
participants: {[USER_B_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}},
participants: {
[USER_B_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
[USER_A_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
},
lastActorAccountID: USER_B_ACCOUNT_ID,
type: CONST.REPORT.TYPE.CHAT,
});
Expand Down
10 changes: 8 additions & 2 deletions tests/ui/UnreadIndicatorsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ function signInAndGetAppWithUnreadChat(): Promise<void> {
lastReadTime: reportAction3CreatedDate,
lastVisibleActionCreated: reportAction9CreatedDate,
lastMessageText: 'Test',
participants: {[USER_B_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}},
participants: {
[USER_B_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
[USER_A_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
},
lastActorAccountID: USER_B_ACCOUNT_ID,
type: CONST.REPORT.TYPE.CHAT,
});
Expand Down Expand Up @@ -301,7 +304,10 @@ describe('Unread Indicators', () => {
lastVisibleActionCreated: DateUtils.getDBTime(utcToZonedTime(NEW_REPORT_FIST_MESSAGE_CREATED_DATE, 'UTC').valueOf()),
lastMessageText: 'Comment 1',
lastActorAccountID: USER_C_ACCOUNT_ID,
participants: {[USER_C_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}},
participants: {
[USER_C_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
[USER_A_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
},
type: CONST.REPORT.TYPE.CHAT,
},
},
Expand Down
Loading
Loading