Skip to content

Commit

Permalink
Merge pull request #30658 from paultsimura/fix/30503-report-skeleton
Browse files Browse the repository at this point in the history
fix: Chat - Skeleton placeholder flickers when opening chat with IOU in offline mode
  • Loading branch information
aldo-expensify authored Nov 7, 2023
2 parents 8c8ba52 + 7727150 commit 4dc53c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ function ReportActionsList({
const lastReportAction = useMemo(() => _.last(sortedReportActions) || {}, [sortedReportActions]);

const listFooterComponent = useCallback(() => {
// Skip this hook on the first render, as we are not sure if more actions are going to be loaded
// Therefore showing the skeleton on footer might be misleading
if (!hasFooterRendered.current) {
// Skip this hook on the first render (when online), as we are not sure if more actions are going to be loaded,
// Therefore showing the skeleton on footer might be misleading.
// When offline, there should be no second render, so we should show the skeleton if the corresponding loading prop is present
if (!isOffline && !hasFooterRendered.current) {
hasFooterRendered.current = true;
return null;
}
Expand All @@ -380,7 +381,7 @@ function ReportActionsList({
lastReportActionName={lastReportAction.actionName}
/>
);
}, [isLoadingInitialReportActions, isLoadingOlderReportActions, lastReportAction.actionName]);
}, [isLoadingInitialReportActions, isLoadingOlderReportActions, lastReportAction.actionName, isOffline]);

const onLayoutInner = useCallback(
(event) => {
Expand All @@ -390,17 +391,18 @@ function ReportActionsList({
);

const listHeaderComponent = useCallback(() => {
if (!hasHeaderRendered.current) {
if (!isOffline && !hasHeaderRendered.current) {
hasHeaderRendered.current = true;
return null;
}

return (
<ListBoundaryLoader
type={CONST.LIST_COMPONENTS.HEADER}
isLoadingNewerReportActions={isLoadingNewerReportActions}
/>
);
}, [isLoadingNewerReportActions]);
}, [isLoadingNewerReportActions, isOffline]);

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ function ReportActionsView(props) {
* displaying.
*/
const loadOlderChats = () => {
// Only fetch more if we are not already fetching so that we don't initiate duplicate requests.
if (props.isLoadingOlderReportActions) {
// Only fetch more if we are neither already fetching (so that we don't initiate duplicate requests) nor offline.
if (props.network.isOffline || props.isLoadingOlderReportActions) {
return;
}

Expand Down

0 comments on commit 4dc53c7

Please sign in to comment.