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

Redundant OpenReport requests when opening a thread #51710

Merged
merged 3 commits into from
Oct 31, 2024
Merged
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
4 changes: 3 additions & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro

const prevReport = usePrevious(report);
const prevUserLeavingStatus = usePrevious(userLeavingStatus);
const lastReportIDFromRoute = usePrevious(reportIDFromRoute);
const [isLinkingToMessage, setIsLinkingToMessage] = useState(!!reportActionIDFromRoute);

const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (value) => value?.accountID});
Expand Down Expand Up @@ -577,7 +578,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
// the ReportScreen never actually unmounts and the reportID in the route also doesn't change.
// Therefore, we need to compare if the existing reportID is the same as the one in the route
// before deciding that we shouldn't call OpenReport.
if (onyxReportID === prevReport?.reportID && (!onyxReportID || onyxReportID === reportIDFromRoute)) {
if (reportIDFromRoute === lastReportIDFromRoute && (!onyxReportID || onyxReportID === reportIDFromRoute)) {
return;
}

Expand All @@ -597,6 +598,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
prevReport?.chatType,
prevReport,
reportIDFromRoute,
lastReportIDFromRoute,
isFocused,
isDeletedParentAction,
prevIsDeletedParentAction,
Expand Down
Loading