From 5db6f6f6093164a744690a8c5ba0cbb8b4616b6b Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 18 Apr 2024 16:24:20 -0400 Subject: [PATCH 1/2] Add logs to debug production chat loading issue --- src/pages/home/ReportScreen.tsx | 13 +++++++++ src/pages/home/report/ReportActionsView.tsx | 30 ++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index cdd843f65fb3..01c3a8189be9 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -28,6 +28,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useViewportOffsetTop from '@hooks/useViewportOffsetTop'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Timing from '@libs/actions/Timing'; +import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import clearReportNotifications from '@libs/Notification/clearReportNotifications'; import Performance from '@libs/Performance'; @@ -625,6 +626,18 @@ function ReportScreen({ ); } + Log.info( + `[ReportScreen] Debug render state - ${JSON.stringify({ + reportMetadata, + shouldShowReportActionList, + isLoading, + shouldShowSkeleton, + isCurrentReportLoadedFromOnyx, + reportID: report.reportID, + reportIDFromRoute, + })}`, + ); + return ( diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1af93186d133..d39f9c0a12d3 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -12,6 +12,7 @@ import usePrevious from '@hooks/usePrevious'; import useWindowDimensions from '@hooks/useWindowDimensions'; import DateUtils from '@libs/DateUtils'; import getIsReportFullyVisible from '@libs/getIsReportFullyVisible'; +import Log from '@libs/Log'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import * as NumberUtils from '@libs/NumberUtils'; import {generateNewRandomInt} from '@libs/NumberUtils'; @@ -298,6 +299,17 @@ function ReportActionsView({ * displaying. */ const loadOlderChats = useCallback(() => { + Log.info( + `[ReportActionsView] loadOlderChats ${JSON.stringify({ + isOffline: network.isOffline, + isLoadingOlderReportActions, + isLoadingInitialReportActions, + oldestReportActionID: oldestReportAction?.reportActionID, + hasCreatedAction, + isTransactionThread: !isEmptyObject(transactionThreadReport), + })}`, + ); + // Only fetch more if we are neither already fetching (so that we don't initiate duplicate requests) nor offline. if (!!network.isOffline || isLoadingOlderReportActions || isLoadingInitialReportActions) { return; @@ -323,13 +335,25 @@ function ReportActionsView({ }, [network.isOffline, isLoadingOlderReportActions, isLoadingInitialReportActions, oldestReportAction, hasCreatedAction, reportID, reportActionIDMap, transactionThreadReport]); const loadNewerChats = useCallback(() => { - if (isLoadingInitialReportActions || isLoadingOlderReportActions || network.isOffline || newestReportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { - return; - } // Determines if loading older reports is necessary when the content is smaller than the list // and there are fewer than 23 items, indicating we've reached the oldest message. const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23; + Log.info( + `[ReportActionsView] loadNewerChats ${JSON.stringify({ + isOffline: network.isOffline, + isLoadingOlderReportActions, + isLoadingInitialReportActions, + newestReportAction: newestReportAction.pendingAction, + firstReportActionID: newestReportAction?.reportActionID, + isLoadingOlderReportsFirstNeeded, + })}`, + ); + + if (isLoadingInitialReportActions || isLoadingOlderReportActions || network.isOffline || newestReportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { + return; + } + if ((reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !isLoadingOlderReportsFirstNeeded)) { handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); } From 23e8a52a055e22caab379c0931b38c085469dda1 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Fri, 19 Apr 2024 11:42:17 -0400 Subject: [PATCH 2/2] Update src/pages/home/ReportScreen.tsx Co-authored-by: Rory Abraham <47436092+roryabraham@users.noreply.github.com> --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 01c3a8189be9..574c4d98f1da 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -626,7 +626,7 @@ function ReportScreen({ ); } - Log.info( + Log.client( `[ReportScreen] Debug render state - ${JSON.stringify({ reportMetadata, shouldShowReportActionList,