From fad6d7910e960989d5dd8929b35ea22538a654b2 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Fri, 13 Dec 2024 17:01:36 +0100 Subject: [PATCH] update useCallback dependencies for draft --- src/hooks/useReportIDs.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/useReportIDs.tsx b/src/hooks/useReportIDs.tsx index 284d80f737f2..878e83cf4d87 100644 --- a/src/hooks/useReportIDs.tsx +++ b/src/hooks/useReportIDs.tsx @@ -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(); @@ -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]);