@@ -23,7 +23,8 @@ import Log from '@libs/Log';
23
23
import memoize from '@libs/memoize' ;
24
24
import isSearchTopmostCentralPane from '@libs/Navigation/isSearchTopmostCentralPane' ;
25
25
import * as ReportUtils from '@libs/ReportUtils' ;
26
- import * as SearchUtils from '@libs/SearchUtils' ;
26
+ import * as SearchQueryUtils from '@libs/SearchQueryUtils' ;
27
+ import * as SearchUIUtils from '@libs/SearchUIUtils' ;
27
28
import Navigation from '@navigation/Navigation' ;
28
29
import type { AuthScreensParamList } from '@navigation/types' ;
29
30
import EmptySearchView from '@pages/Search/EmptySearchView' ;
@@ -61,11 +62,11 @@ function mapToItemWithSelectionInfo(
61
62
canSelectMultiple : boolean ,
62
63
shouldAnimateInHighlight : boolean ,
63
64
) {
64
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
65
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
65
66
return item ;
66
67
}
67
68
68
- return SearchUtils . isTransactionListItemType ( item )
69
+ return SearchUIUtils . isTransactionListItemType ( item )
69
70
? mapToTransactionItemWithSelectionInfo ( item , selectedTransactions , canSelectMultiple , shouldAnimateInHighlight )
70
71
: {
71
72
...item ,
@@ -143,7 +144,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
143
144
144
145
const getItemHeight = useCallback (
145
146
( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
146
- if ( SearchUtils . isTransactionListItemType ( item ) || SearchUtils . isReportActionListItemType ( item ) ) {
147
+ if ( SearchUIUtils . isTransactionListItemType ( item ) || SearchUIUtils . isReportActionListItemType ( item ) ) {
147
148
return isLargeScreenWidth ? variables . optionRowHeight + listItemPadding : transactionItemMobileHeight + listItemPadding ;
148
149
}
149
150
@@ -190,9 +191,9 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
190
191
const isDataLoaded = searchResults ?. data !== undefined && searchResults ?. search ?. type === type && searchResults ?. search ?. status === status ;
191
192
const shouldShowLoadingState = ! isOffline && ! isDataLoaded ;
192
193
const shouldShowLoadingMoreItems = ! shouldShowLoadingState && searchResults ?. search ?. isLoading && searchResults ?. search ?. offset > 0 ;
193
- const isSearchResultsEmpty = ! searchResults ?. data || SearchUtils . isSearchResultsEmpty ( searchResults ) ;
194
+ const isSearchResultsEmpty = ! searchResults ?. data || SearchUIUtils . isSearchResultsEmpty ( searchResults ) ;
194
195
const prevIsSearchResultEmpty = usePrevious ( isSearchResultsEmpty ) ;
195
- const data = searchResults === undefined ? [ ] : SearchUtils . getSections ( type , status , searchResults . data , searchResults . search ) ;
196
+ const data = searchResults === undefined ? [ ] : SearchUIUtils . getSections ( type , status , searchResults . data , searchResults . search ) ;
196
197
197
198
useEffect ( ( ) => {
198
199
/** We only want to display the skeleton for the status filters the first time we load them for a specific data type */
@@ -275,8 +276,8 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
275
276
return < FullPageOfflineBlockingView > { null } </ FullPageOfflineBlockingView > ;
276
277
}
277
278
278
- const ListItem = SearchUtils . getListItem ( type , status ) ;
279
- const sortedData = SearchUtils . getSortedSections ( type , status , data , sortBy , sortOrder ) ;
279
+ const ListItem = SearchUIUtils . getListItem ( type , status ) ;
280
+ const sortedData = SearchUIUtils . getSortedSections ( type , status , data , sortBy , sortOrder ) ;
280
281
const sortedSelectedData = sortedData . map ( ( item ) => {
281
282
const baseKey = `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ ( item as TransactionListItemType ) . transactionID } ` ;
282
283
// Check if the base key matches the newSearchResultKey (TransactionListItemType)
@@ -303,10 +304,10 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
303
304
}
304
305
305
306
const toggleTransaction = ( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
306
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
307
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
307
308
return ;
308
309
}
309
- if ( SearchUtils . isTransactionListItemType ( item ) ) {
310
+ if ( SearchUIUtils . isTransactionListItemType ( item ) ) {
310
311
if ( ! item . keyForList ) {
311
312
return ;
312
313
}
@@ -337,21 +338,21 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
337
338
338
339
const openReport = ( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
339
340
const isFromSelfDM = item . reportID === CONST . REPORT . UNREPORTED_REPORTID ;
340
- let reportID = SearchUtils . isTransactionListItemType ( item ) && ( ! item . isFromOneTransactionReport || isFromSelfDM ) ? item . transactionThreadReportID : item . reportID ;
341
+ let reportID = SearchUIUtils . isTransactionListItemType ( item ) && ( ! item . isFromOneTransactionReport || isFromSelfDM ) ? item . transactionThreadReportID : item . reportID ;
341
342
342
343
if ( ! reportID ) {
343
344
return ;
344
345
}
345
346
346
347
// If we're trying to open a legacy transaction without a transaction thread, let's create the thread and navigate the user
347
- if ( SearchUtils . isTransactionListItemType ( item ) && reportID === '0' && item . moneyRequestReportActionID ) {
348
+ if ( SearchUIUtils . isTransactionListItemType ( item ) && reportID === '0' && item . moneyRequestReportActionID ) {
348
349
reportID = ReportUtils . generateReportID ( ) ;
349
350
SearchActions . createTransactionThread ( hash , item . transactionID , reportID , item . moneyRequestReportActionID ) ;
350
351
}
351
352
352
353
const backTo = Navigation . getActiveRoute ( ) ;
353
354
354
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
355
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
355
356
const reportActionID = item . reportActionID ;
356
357
Navigation . navigate ( ROUTES . SEARCH_REPORT . getRoute ( { reportID, reportActionID, backTo} ) ) ;
357
358
return ;
@@ -387,11 +388,11 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
387
388
} ;
388
389
389
390
const onSortPress = ( column : SearchColumnType , order : SortOrder ) => {
390
- const newQuery = SearchUtils . buildSearchQueryString ( { ...queryJSON , sortBy : column , sortOrder : order } ) ;
391
+ const newQuery = SearchQueryUtils . buildSearchQueryString ( { ...queryJSON , sortBy : column , sortOrder : order } ) ;
391
392
navigation . setParams ( { q : newQuery } ) ;
392
393
} ;
393
394
394
- const shouldShowYear = SearchUtils . shouldShowYear ( searchResults ?. data ) ;
395
+ const shouldShowYear = SearchUIUtils . shouldShowYear ( searchResults ?. data ) ;
395
396
const shouldShowSorting = sortableSearchStatuses . includes ( status ) ;
396
397
397
398
return (
@@ -416,7 +417,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
416
417
)
417
418
}
418
419
isSelected = { ( item ) =>
419
- status !== CONST . SEARCH . STATUS . EXPENSE . ALL && SearchUtils . isReportListItemType ( item )
420
+ status !== CONST . SEARCH . STATUS . EXPENSE . ALL && SearchUIUtils . isReportListItemType ( item )
420
421
? item . transactions . some ( ( transaction ) => selectedTransactions [ transaction . keyForList ] ?. isSelected )
421
422
: ! ! item . isSelected
422
423
}
0 commit comments