Skip to content

Commit af28f6e

Browse files
committed
revert
1 parent 08649be commit af28f6e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/hooks/useSearchHighlightAndScroll.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function useSearchHighlightAndScroll({searchResults, transactions, previousTrans
2727
// Ref to track if the search was triggered by this hook
2828
const triggeredByHookRef = useRef(false);
2929
const searchTriggeredRef = useRef(false);
30-
const hasItemBeenAddedRef = useRef(false);
3130
const previousSearchResults = usePrevious(searchResults?.data);
3231
const [newSearchResultKey, setNewSearchResultKey] = useState<string | null>(null);
3332
const highlightedIDs = useRef<Set<string>>(new Set());
@@ -52,11 +51,6 @@ function useSearchHighlightAndScroll({searchResults, transactions, previousTrans
5251
const hasTransactionChange = !isEqual(transactionIDList, previousTransactionIDList);
5352
const hasReportActionChange = !isEqual(reportActionIDList, previousReportActionIDList);
5453

55-
// We only want to highlight new items only if addition of transactions or report actions triggered the search.
56-
// This is because on deletion of items sometimes the BE returns old items in place of the deleted ones
57-
// but we don't want to highlight these old items although they are new to the current search result.
58-
hasItemBeenAddedRef.current = isChat ? reportActionIDList.length > previousReportActionIDList.length : transactionIDList.length > previousTransactionIDList.length;
59-
6054
// Check if there is a change in transaction or report action list
6155
if ((!isChat && hasTransactionChange) || (isChat && hasReportActionChange)) {
6256
// Set the flag indicating the search is triggered by the hook
@@ -98,7 +92,7 @@ function useSearchHighlightAndScroll({searchResults, transactions, previousTrans
9892
// Find new report action IDs that are not in the previousReportActionIDs and not already highlighted
9993
const newReportActionIDs = currentReportActionIDs.filter((id) => !previousReportActionIDs.includes(id) && !highlightedIDs.current.has(id));
10094

101-
if (!triggeredByHookRef.current || newReportActionIDs.length === 0 || !hasItemBeenAddedRef.current) {
95+
if (!triggeredByHookRef.current || newReportActionIDs.length === 0) {
10296
return;
10397
}
10498

@@ -114,7 +108,7 @@ function useSearchHighlightAndScroll({searchResults, transactions, previousTrans
114108
// Find new transaction IDs that are not in the previousTransactionIDs and not already highlighted
115109
const newTransactionIDs = currentTransactionIDs.filter((id) => !previousTransactionIDs.includes(id) && !highlightedIDs.current.has(id));
116110

117-
if (!triggeredByHookRef.current || newTransactionIDs.length === 0 || !hasItemBeenAddedRef.current) {
111+
if (!triggeredByHookRef.current || newTransactionIDs.length === 0) {
118112
return;
119113
}
120114

0 commit comments

Comments
 (0)