Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perf] Improve open report action via search panel performance #47726

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ const CONST = {
RESIZE_DEBOUNCE_TIME: 100,
UNREAD_UPDATE_DEBOUNCE_TIME: 300,
SEARCH_FILTER_OPTIONS: 'search_filter_options',
USE_DEBOUNCED_STATE_DELAY: 300,
},
PRIORITY_MODE: {
GSD: 'gsd',
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDebouncedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CONST from '@src/CONST';
* A React hook that provides a state and its debounced version.
*
* @param initialValue - The initial value of the state.
* @param delay - The debounce delay in milliseconds. Defaults to SEARCH_OPTION_LIST_DEBOUNCE_TIME = 300ms.
* @param delay - The debounce delay in milliseconds. Defaults to USE_DEBOUNCED_STATE_DELAY = 300ms.
* @returns A tuple containing:
* - The current state value.
* - The debounced state value.
Expand All @@ -17,7 +17,7 @@ import CONST from '@src/CONST';
* @example
* const [value, debouncedValue, setValue] = useDebouncedState<string>("", 300);
*/
function useDebouncedState<T>(initialValue: T, delay: number = CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME): [T, T, (value: T) => void] {
function useDebouncedState<T>(initialValue: T, delay: number = CONST.TIMING.USE_DEBOUNCED_STATE_DELAY): [T, T, (value: T) => void] {
kacper-mikolajczak marked this conversation as resolved.
Show resolved Hide resolved
const [value, setValue] = useState(initialValue);
const [debouncedValue, setDebouncedValue] = useState(initialValue);
const debouncedSetDebouncedValue = useRef(debounce(setDebouncedValue, delay)).current;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ChatFinderPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as Report from '@userActions/Report';
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import ChatFinderPageFooter from './ChatFinderPageFooter';
Expand Down Expand Up @@ -153,8 +154,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa
}

if (option.reportID) {
updateSearchValue('');
Navigation.dismissModal(option.reportID);
Navigation.closeAndNavigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID));
} else {
Report.navigateToAndOpenReport(option.login ? [option.login] : []);
}
Expand Down
Loading