Skip to content

Commit 72f4419

Browse files
authored
Merge pull request #58051 from huult/56947-chat-duplication
Prevent multiple chats from opening when switching quickly
2 parents a3c591b + 784efee commit 72f4419

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/pages/home/sidebar/SidebarLinks.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@ function SidebarLinks({insets, optionListItems, isLoading, priorityMode = CONST.
6868
// or when continuously clicking different LHNs, only apply to small screen
6969
// since getTopmostReportId always returns on other devices
7070
const reportActionID = Navigation.getTopmostReportActionId();
71-
if ((option.reportID === Navigation.getTopmostReportId() && !reportActionID) || (shouldUseNarrowLayout && isActiveReport(option.reportID) && !reportActionID)) {
71+
72+
// Prevent opening a new Report page if the user quickly taps on another conversation
73+
// before the first one is displayed.
74+
const shouldBlockReportNavigation = Navigation.getActiveRoute() !== '/home' && shouldUseNarrowLayout;
75+
76+
if (
77+
(option.reportID === Navigation.getTopmostReportId() && !reportActionID) ||
78+
(shouldUseNarrowLayout && isActiveReport(option.reportID) && !reportActionID) ||
79+
shouldBlockReportNavigation
80+
) {
7281
return;
7382
}
7483
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID));

tests/perf-test/SidebarLinks.perf-test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jest.mock('../../src/libs/Navigation/Navigation', () => ({
1515
navigate: jest.fn(),
1616
isActiveRoute: jest.fn(),
1717
getTopmostReportId: jest.fn(),
18+
getActiveRoute: jest.fn(),
1819
getTopmostReportActionId: jest.fn(),
1920
isNavigationReady: jest.fn(() => Promise.resolve()),
2021
isDisplayedInModal: jest.fn(() => false),

0 commit comments

Comments
 (0)