Skip to content

Commit

Permalink
Merge pull request #54191 from callstack-internal/gedu/54094_useRepor…
Browse files Browse the repository at this point in the history
…tIds_draft_update

[Performance] Update useReportIDs to check draft amount
  • Loading branch information
mountiny authored Dec 19, 2024
2 parents 13286be + cec8f70 commit 6da9c7b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hooks/useReportIDs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function ReportIDsContextProvider({
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: (c) => mapOnyxCollectionItems(c, policySelector)});
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [reportsDrafts] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT);
const draftAmount = Object.keys(reportsDrafts ?? {}).length;
const [betas] = useOnyx(ONYXKEYS.BETAS);

const {shouldUseNarrowLayout} = useResponsiveLayout();
Expand All @@ -70,9 +71,9 @@ function ReportIDsContextProvider({
const getOrderedReportIDs = useCallback(
(currentReportID?: string) =>
SidebarUtils.getOrderedReportIDs(currentReportID ?? null, chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs),
// we need reports draft in deps array for reloading of list when reportsDrafts will change
// we need reports draft in deps array to reload the list when a draft is added or removed
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs, reportsDrafts],
[chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs, draftAmount],
);

const orderedReportIDs = useMemo(() => getOrderedReportIDs(), [getOrderedReportIDs]);
Expand Down

0 comments on commit 6da9c7b

Please sign in to comment.