Skip to content

Commit

Permalink
Remove containerHeight from ReportActionsSkeletonView because onLayou…
Browse files Browse the repository at this point in the history
…tEvent is too slow
  • Loading branch information
ospfranco committed Sep 14, 2023
1 parent d761db0 commit ffaf7a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/components/ReportActionsSkeletonView/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import {View, Dimensions} from 'react-native';
import SkeletonViewLines from './SkeletonViewLines';
import CONST from '../../CONST';

const propTypes = {
/** Height of the container component */
containerHeight: PropTypes.number.isRequired,

/** Whether to animate the skeleton view */
shouldAnimate: PropTypes.bool,
Expand All @@ -18,7 +16,7 @@ const defaultProps = {

function ReportActionsSkeletonView(props) {
// Determines the number of content items based on container height
const possibleVisibleContentItems = Math.ceil(props.containerHeight / CONST.CHAT_SKELETON_VIEW.AVERAGE_ROW_HEIGHT);
const possibleVisibleContentItems = Math.ceil(Dimensions.get('window').height / CONST.CHAT_SKELETON_VIEW.AVERAGE_ROW_HEIGHT);
const skeletonViewLines = [];
for (let index = 0; index < possibleVisibleContentItems; index++) {
const iconIndex = (index + 1) % 4;
Expand Down
29 changes: 15 additions & 14 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,22 +368,23 @@ function ReportScreen({
/>
)}

{/* Note: The ReportActionsSkeletonView should be allowed to mount even if the initial report actions are not loaded. If we prevent rendering the report while they are loading then
we'll unnecessarily unmount the ReportActionsView which will clear the new marker lines initial state. */}
{(!isReportReadyForDisplay || isLoadingInitialReportActions || isLoading) && <ReportActionsSkeletonView containerHeight={skeletonViewContainerHeight} />}
{/* Note: The ReportActionsSkeletonView should be allowed to mount even if the initial report actions are not loaded.
If we prevent rendering the report while they are loading then
we'll unnecessarily unmount the ReportActionsView which will clear the new marker lines initial state. */}
{(!isReportReadyForDisplay || isLoadingInitialReportActions || isLoading) &&
<ReportActionsSkeletonView />
}

{isReportReadyForDisplay ? (
<>
<ReportFooter
pendingAction={addWorkspaceRoomOrChatPendingAction}
isOffline={network.isOffline}
reportActions={reportActions}
report={report}
isComposerFullSize={isComposerFullSize}
onSubmitComment={onSubmitComment}
policies={policies}
/>
</>
<ReportFooter
pendingAction={addWorkspaceRoomOrChatPendingAction}
isOffline={network.isOffline}
reportActions={reportActions}
report={report}
isComposerFullSize={isComposerFullSize}
onSubmitComment={onSubmitComment}
policies={policies}
/>
) : (
<ReportFooter
shouldDisableCompose
Expand Down

0 comments on commit ffaf7a8

Please sign in to comment.