From 2b77a0c4a42ba29acd258ee7c7fb33bab59b771e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Fri, 16 Aug 2024 13:35:16 +0200 Subject: [PATCH 1/5] fix useDebouncedState default delay reference --- src/CONST.ts | 1 + src/hooks/useDebouncedState.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index f1e4a3bb46d5..82f7b76a72f2 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -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', diff --git a/src/hooks/useDebouncedState.ts b/src/hooks/useDebouncedState.ts index 6fda8f7d54d4..2b457dabe8a0 100644 --- a/src/hooks/useDebouncedState.ts +++ b/src/hooks/useDebouncedState.ts @@ -17,7 +17,7 @@ import CONST from '@src/CONST'; * @example * const [value, debouncedValue, setValue] = useDebouncedState("", 300); */ -function useDebouncedState(initialValue: T, delay: number = CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME): [T, T, (value: T) => void] { +function useDebouncedState(initialValue: T, delay: number = CONST.TIMING.USE_DEBOUNCED_STATE_DELAY): [T, T, (value: T) => void] { const [value, setValue] = useState(initialValue); const [debouncedValue, setDebouncedValue] = useState(initialValue); const debouncedSetDebouncedValue = useRef(debounce(setDebouncedValue, delay)).current; From 01a72e15f241ae1d0120bfe6845fabd47d4e1e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Fri, 16 Aug 2024 16:14:17 +0200 Subject: [PATCH 2/5] remove unnecessary updateSearchValue call --- src/pages/ChatFinderPage/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/ChatFinderPage/index.tsx b/src/pages/ChatFinderPage/index.tsx index 1246bc156278..7d1541da3cbb 100644 --- a/src/pages/ChatFinderPage/index.tsx +++ b/src/pages/ChatFinderPage/index.tsx @@ -153,7 +153,6 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa } if (option.reportID) { - updateSearchValue(''); Navigation.dismissModal(option.reportID); } else { Report.navigateToAndOpenReport(option.login ? [option.login] : []); From b35bcb760a89b284db04f96fcbacf849436501de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Fri, 16 Aug 2024 16:14:45 +0200 Subject: [PATCH 3/5] replace dismissModal with navigate --- src/pages/ChatFinderPage/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/ChatFinderPage/index.tsx b/src/pages/ChatFinderPage/index.tsx index 7d1541da3cbb..ba227dad1277 100644 --- a/src/pages/ChatFinderPage/index.tsx +++ b/src/pages/ChatFinderPage/index.tsx @@ -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'; @@ -153,7 +154,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa } if (option.reportID) { - Navigation.dismissModal(option.reportID); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID)); } else { Report.navigateToAndOpenReport(option.login ? [option.login] : []); } From da72355cb274fb93bd7a7ce4c769c9d308a37acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Thu, 22 Aug 2024 12:47:32 +0200 Subject: [PATCH 4/5] replace navigate with closeAndNavigate --- src/pages/ChatFinderPage/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ChatFinderPage/index.tsx b/src/pages/ChatFinderPage/index.tsx index ba227dad1277..fb17f2d3d8b0 100644 --- a/src/pages/ChatFinderPage/index.tsx +++ b/src/pages/ChatFinderPage/index.tsx @@ -154,7 +154,7 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa } if (option.reportID) { - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID)); + Navigation.closeAndNavigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID)); } else { Report.navigateToAndOpenReport(option.login ? [option.login] : []); } From 64c8d374399a71c7fe30ef036b1e709c4056533e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Mon, 26 Aug 2024 18:06:04 +0200 Subject: [PATCH 5/5] update useDebouncedState comment --- src/hooks/useDebouncedState.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useDebouncedState.ts b/src/hooks/useDebouncedState.ts index 2b457dabe8a0..8d7d43cb6f9c 100644 --- a/src/hooks/useDebouncedState.ts +++ b/src/hooks/useDebouncedState.ts @@ -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.