From 3f5906b18d17d21b6efef9cbc22669900c821c10 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 2 Dec 2025 17:16:29 +0300 Subject: [PATCH] save access search isLoading --- src/components/MoneyReportHeader.tsx | 6 +++--- .../MoneyRequestReportNavigation.tsx | 2 +- src/components/Search/index.tsx | 2 +- .../Search/TransactionGroupListItem.tsx | 4 ++-- src/hooks/useSearchHighlightAndScroll.ts | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 2339d0ef7dc9d..4560159bcdcf4 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -487,7 +487,7 @@ function MoneyReportHeader({ offset: 0, queryJSON: currentSearchQueryJSON, isOffline, - isLoading: !!currentSearchResults?.search.isLoading, + isLoading: !!currentSearchResults?.search?.isLoading, }); } } @@ -507,7 +507,7 @@ function MoneyReportHeader({ currentSearchQueryJSON, currentSearchKey, isOffline, - currentSearchResults?.search.isLoading, + currentSearchResults?.search?.isLoading, ], ); @@ -799,7 +799,7 @@ function MoneyReportHeader({ offset: 0, queryJSON: currentSearchQueryJSON, isOffline, - isLoading: !!currentSearchResults?.search.isLoading, + isLoading: !!currentSearchResults?.search?.isLoading, }); } }} diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx index f4c22518da677..9943ce4f6c160 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx @@ -111,7 +111,7 @@ function MoneyRequestReportNavigation({reportID, shouldDisplayNarrowVersion}: Mo prevReportsLength: allReports.length, shouldCalculateTotals: false, searchKey: lastSearchQuery.searchKey, - isLoading: !!currentSearchResults?.search.isLoading, + isLoading: !!currentSearchResults?.search?.isLoading, }); } diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index a07e2ff19403b..3554e9b8b997a 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -451,7 +451,7 @@ function Search({ return; } - handleSearch({queryJSON, searchKey, offset, shouldCalculateTotals, prevReportsLength: filteredDataLength, isLoading: !!searchResults?.search.isLoading}); + handleSearch({queryJSON, searchKey, offset, shouldCalculateTotals, prevReportsLength: filteredDataLength, isLoading: !!searchResults?.search?.isLoading}); // We don't need to run the effect on change of isFocused. // eslint-disable-next-line react-compiler/react-compiler diff --git a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx index cb60b77960489..fe2d0b78d623a 100644 --- a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx @@ -147,10 +147,10 @@ function TransactionGroupListItem({ searchKey: undefined, offset: (transactionsSnapshot?.search?.offset ?? 0) + pageSize, shouldCalculateTotals: false, - isLoading: !!transactionsSnapshot?.search.isLoading, + isLoading: !!transactionsSnapshot?.search?.isLoading, }); }, - [groupItem.transactionsQueryJSON, transactionsSnapshot?.search?.offset, transactionsSnapshot?.search.isLoading], + [groupItem.transactionsQueryJSON, transactionsSnapshot?.search?.offset, transactionsSnapshot?.search?.isLoading], ); const animatedHighlightStyle = useAnimatedHighlightStyle({ diff --git a/src/hooks/useSearchHighlightAndScroll.ts b/src/hooks/useSearchHighlightAndScroll.ts index ddd1334a8d9b2..bb2826105dc40 100644 --- a/src/hooks/useSearchHighlightAndScroll.ts +++ b/src/hooks/useSearchHighlightAndScroll.ts @@ -134,7 +134,7 @@ function useSearchHighlightAndScroll({ // Trigger the search // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { - search({queryJSON, searchKey, offset, shouldCalculateTotals, isLoading: !!searchResults?.search.isLoading}); + search({queryJSON, searchKey, offset, shouldCalculateTotals, isLoading: !!searchResults?.search?.isLoading}); }); // Set the ref to prevent further triggers until reset @@ -154,16 +154,16 @@ function useSearchHighlightAndScroll({ searchResults?.data, existingSearchResultIDs, isOffline, - searchResults?.search.isLoading, + searchResults?.search?.isLoading, ]); useEffect(() => { - if (searchResults?.search.isLoading) { + if (searchResults?.search?.isLoading) { return; } searchTriggeredRef.current = false; - }, [searchResults?.search.isLoading]); + }, [searchResults?.search?.isLoading]); // Initialize the set with existing IDs only once useEffect(() => {