Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use the full-height ReportActionsSkeletonView in all cases #34114

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/pages/home/report/ListBoundaryLoader/ListBoundaryLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ function ListBoundaryLoader({type, isLoadingOlderReportActions, isLoadingInitial
// We use two different loading components for the header and footer
// to reduce the jumping effect when the user is scrolling to the newer report actions
if (type === CONST.LIST_COMPONENTS.FOOTER) {
// We are actively fetching older report actions from the server – need to show the skeleton view
if (isLoadingOlderReportActions) {
return <ReportActionsSkeletonView />;
}

// Make sure the report chat is not loaded till the beginning. This is so we do not show the
// skeleton view above the "created" action in a newly generated optimistic chat or one with not
// that many comments.
// Also, if we are offline and the report is not yet loaded till the beginning, we assume there are more actions to load,
// therefore show the skeleton view, even though the actions are not loading.
if (lastReportActionName !== CONST.REPORT.ACTIONS.TYPE.CREATED && (isLoadingInitialReportActions || isOffline)) {
return <ReportActionsSkeletonView possibleVisibleContentItems={3} />;
/*
Ensure that the report chat is not loaded until the beginning.
This is to avoid displaying the skeleton view above the "created" action in a newly generated optimistic chat or one with not that many comments.
Additionally, if we are offline and the report is not loaded until the beginning, we assume there are more actions to load;
Therefore, show the skeleton view even though the actions are not actually loading.
*/
const isReportLoadedUntilBeginning = lastReportActionName === CONST.REPORT.ACTIONS.TYPE.CREATED;
if (!isReportLoadedUntilBeginning && (isLoadingInitialReportActions || isOffline)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have such complex long conditions it is better to split them into flags. For example, !isReportLoadedUntilBeginning && (isLoadingInitialReportActions || isOffline can be one flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done ✔️

return <ReportActionsSkeletonView />;
}
}
if (type === CONST.LIST_COMPONENTS.HEADER && isLoadingNewerReportActions) {
Expand Down
Loading