From 9dc06e2cd847267aaef2d686bb7b748a12e96a80 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 24 Jul 2024 15:28:06 +0200 Subject: [PATCH 1/4] Replace withOnyx with useOnyx to obtain reportMetadata in ReportScreen --- src/pages/home/ReportScreen.tsx | 54 +++++++++++++-------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 6535d35c55f9..82145b721d35 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -68,9 +68,6 @@ type ReportScreenOnyxProps = { /** The policies which the user has access to */ policies: OnyxCollection; - - /** The report metadata loading states */ - reportMetadata: OnyxEntry; }; type OnyxHOCProps = { @@ -110,22 +107,7 @@ function getParentReportAction(parentReportActions: OnyxEntry `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`, - initialValue: { - isLoadingInitialReportActions: true, - isLoadingOlderReportActions: false, - hasLoadingOlderReportActionsError: false, - isLoadingNewerReportActions: false, - hasLoadingNewerReportActionsError: false, - }, - }, betas: { key: ONYXKEYS.BETAS, }, @@ -880,7 +869,6 @@ export default withCurrentReportID( ReportScreen, (prevProps, nextProps) => prevProps.isSidebarLoaded === nextProps.isSidebarLoaded && - lodashIsEqual(prevProps.reportMetadata, nextProps.reportMetadata) && lodashIsEqual(prevProps.betas, nextProps.betas) && lodashIsEqual(prevProps.policies, nextProps.policies) && prevProps.currentReportID === nextProps.currentReportID && From 620dc16a11b95e1e0c2be69669d883b23e520798 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 24 Jul 2024 15:31:53 +0200 Subject: [PATCH 2/4] cleanup code --- src/pages/home/ReportScreen.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 82145b721d35..68ca4adc5a1d 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -438,14 +438,6 @@ function ReportScreen({betas = [], route, markReadyForHydration, policies = {}, } if (!wasReportAccessibleRef.current && !firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata?.isLoadingInitialReportActions && !userLeavingStatus) { - console.log('shouldShowNotFoundPage', { - wasReportAccessibleRef: wasReportAccessibleRef.current, - firstRenderRef: firstRenderRef.current, - isOptimisticDelete, - reportID: report.reportID, - userLeavingStatus, - isLoadingInitialReportActions: reportMetadata?.isLoadingInitialReportActions, - }); return true; } From 661aa8e1dd01f94f5e00a7e2c98b38f488c68a4a Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 24 Jul 2024 16:12:41 +0200 Subject: [PATCH 3/4] Add defaultReportMetadata --- src/pages/home/ReportScreen.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 68ca4adc5a1d..83cf5085aaba 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -107,6 +107,14 @@ function getParentReportAction(parentReportActions: OnyxEntry Date: Wed, 24 Jul 2024 16:15:29 +0200 Subject: [PATCH 4/4] Fix getting routes in resetHomeRouteParams --- src/libs/actions/Session/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index a71310119ab4..6f29382f25a8 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -677,7 +677,7 @@ function clearSignInData() { */ function resetHomeRouteParams() { Navigation.isNavigationReady().then(() => { - const routes = navigationRef.current?.getState().routes; + const routes = navigationRef.current?.getState()?.routes; const homeRoute = routes?.find((route) => route.name === SCREENS.HOME); const emptyParams: Record = {};