From d715ed874ca0df7aa7110cb9f25ee9ed04b0954e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 26 Dec 2024 23:44:56 +0700 Subject: [PATCH] fix lhn filter is resets to all when sending invoice for the first time on a workspace --- .../home/sidebar/SidebarScreen/BaseSidebarScreen.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.tsx b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.tsx index a1e4f0e4a22a..580f94e0f2f4 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.tsx +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.tsx @@ -15,13 +15,15 @@ import SidebarLinksData from '@pages/home/sidebar/SidebarLinksData'; import Timing from '@userActions/Timing'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; function BaseSidebarScreen() { const styles = useThemeStyles(); const activeWorkspaceID = useActiveWorkspaceFromNavigationState(); const {translate} = useLocalize(); const {shouldUseNarrowLayout} = useResponsiveLayout(); - const [activeWorkspace] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID ?? CONST.DEFAULT_NUMBER_ID}`); + const [activeWorkspace, activeWorkspaceResult] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID ?? CONST.DEFAULT_NUMBER_ID}`); + const isLoading = isLoadingOnyxValue(activeWorkspaceResult); useEffect(() => { Performance.markStart(CONST.TIMING.SIDEBAR_LOADED); @@ -29,13 +31,13 @@ function BaseSidebarScreen() { }, []); useEffect(() => { - if (!!activeWorkspace || activeWorkspaceID === undefined) { + if (!!activeWorkspace || activeWorkspaceID === undefined || isLoading) { return; } Navigation.navigateWithSwitchPolicyID({policyID: undefined}); updateLastAccessedWorkspace(undefined); - }, [activeWorkspace, activeWorkspaceID]); + }, [activeWorkspace, activeWorkspaceID, isLoading]); const shouldDisplaySearch = shouldUseNarrowLayout;