Skip to content

Commit

Permalink
Merge pull request #40501 from janicduplessis/@janic/logs
Browse files Browse the repository at this point in the history
Add logs to debug production chat loading issue
  • Loading branch information
roryabraham authored Apr 23, 2024
2 parents f30d4a0 + 23e8a52 commit 52a59cd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -625,6 +626,18 @@ function ReportScreen({
);
}

Log.client(
`[ReportScreen] Debug render state - ${JSON.stringify({
reportMetadata,
shouldShowReportActionList,
isLoading,
shouldShowSkeleton,
isCurrentReportLoadedFromOnyx,
reportID: report.reportID,
reportIDFromRoute,
})}`,
);

return (
<ActionListContext.Provider value={actionListValue}>
<ReactionListContext.Provider value={reactionListRef}>
Expand Down
30 changes: 27 additions & 3 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -299,6 +300,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;
Expand All @@ -324,13 +336,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});
}
Expand Down

0 comments on commit 52a59cd

Please sign in to comment.