Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 3 additions & 6 deletions src/components/InvertedFlatList/BaseInvertedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class BaseInvertedFlatList extends Component {
this.sizeMap = {};
}

shouldComponentUpdate(prevProps) {
// The FlatList itself should only re-render if items are added
return prevProps.data.length !== this.props.data.length;
}

/**
* Return default or previously cached height for
* a renderItem row
Expand Down Expand Up @@ -135,8 +130,10 @@ class BaseInvertedFlatList extends Component {
inverted
renderItem={this.renderItem}
getItemLayout={this.getItemLayout}
removeClippedSubviews
bounces={false}
removeClippedSubviews
maxToRenderPerBatch={15}
updateCellsBatchingPeriod={40}
/>
);
}
Expand Down
25 changes: 8 additions & 17 deletions src/page/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {Component} from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import ReportActionItemSingle from './ReportActionItemSingle';
import ReportActionPropTypes from './ReportActionPropTypes';
Expand All @@ -12,22 +12,13 @@ const propTypes = {
displayAsGroup: PropTypes.bool.isRequired,
};

class ReportActionItem extends Component {
shouldComponentUpdate(nextProps) {
// If the grouping changes then we want to update the UI
return nextProps.displayAsGroup !== this.props.displayAsGroup;
}

render() {
return (
<>
{!this.props.displayAsGroup
? <ReportActionItemSingle action={this.props.action} />
: <ReportActionItemGrouped action={this.props.action} />}
</>
);
}
}
const ReportActionItem = props => (
<>
{!props.displayAsGroup
? <ReportActionItemSingle action={props.action} />
: <ReportActionItemGrouped action={props.action} />}
</>
);

ReportActionItem.propTypes = propTypes;

Expand Down
20 changes: 7 additions & 13 deletions src/page/home/report/ReportActionItemGrouped.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@ const propTypes = {
action: PropTypes.shape(ReportActionPropTypes).isRequired,
};

class ReportActionItemGrouped extends React.PureComponent {
render() {
const {action} = this.props;
return (
<View style={[styles.chatItem]}>
<View style={[styles.chatItemRightGrouped]}>
<ReportActionItemMessage action={action} />
</View>
</View>
);
}
}
const ReportActionItemGrouped = ({action}) => (
<View style={[styles.chatItem]}>
<View style={[styles.chatItemRightGrouped]}>
<ReportActionItemMessage action={action} />
</View>
</View>
);

ReportActionItemGrouped.propTypes = propTypes;

export default ReportActionItemGrouped;
50 changes: 23 additions & 27 deletions src/page/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,31 @@ const propTypes = {
action: PropTypes.shape(ReportActionPropTypes).isRequired,
};

class ReportActionItemSingle extends React.PureComponent {
render() {
const {action} = this.props;
const avatarUrl = action.automatic
? `${CONST.CLOUDFRONT_URL}/images/icons/concierge_2019.svg`
: action.avatar;
return (
<View style={[styles.chatItem]}>
<Image
source={{uri: avatarUrl}}
style={[styles.actionAvatar]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
{_.map(action.person, (fragment, index) => (
<ReportActionItemFragment
key={`person-${action.sequenceNumber}-${index}`}
fragment={fragment}
/>
))}
<ReportActionItemDate timestamp={action.timestamp} />
</View>
<ReportActionItemMessage action={action} />
const ReportActionItemSingle = ({action}) => {
const avatarUrl = action.automatic
? `${CONST.CLOUDFRONT_URL}/images/icons/concierge_2019.svg`
: action.avatar;
return (
<View style={[styles.chatItem]}>
<Image
source={{uri: avatarUrl}}
style={[styles.actionAvatar]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
{_.map(action.person, (fragment, index) => (
<ReportActionItemFragment
key={`person-${action.sequenceNumber}-${index}`}
fragment={fragment}
/>
))}
<ReportActionItemDate timestamp={action.timestamp} />
</View>
<ReportActionItemMessage action={action} />
</View>
);
}
}
</View>
);
};

ReportActionItemSingle.propTypes = propTypes;

export default ReportActionItemSingle;