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

Swap out trivial usages of sequenceNumber in UI keys #12606

Merged
merged 5 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/IOUQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const defaultProps = {
const IOUQuote = props => (
<View style={[styles.chatItemMessage]}>
{_.map(props.action.message, (fragment, index) => (
<View key={`iouQuote-${props.action.sequenceNumber}-${index}`} style={[styles.alignItemsStart, styles.blockquote]}>
<View key={`iouQuote-${props.action.reportActionID}-${index}`} style={[styles.alignItemsStart, styles.blockquote]}>
<Text style={[styles.chatItemMessage]}>
{Str.htmlDecode(fragment.text)}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ReportActionItemMessage = props => (
<View style={[styles.chatItemMessage, ...props.style]}>
{_.map(_.compact(props.action.previousMessage || props.action.message), (fragment, index) => (
<ReportActionItemFragment
key={`actionFragment-${props.action.sequenceNumber}-${index}`}
key={`actionFragment-${props.action.reportActionID}-${index}`}
fragment={fragment}
isAttachment={props.action.isAttachment}
attachmentInfo={props.action.attachmentInfo}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const ReportActionItemSingle = (props) => {
>
{_.map(personArray, (fragment, index) => (
<ReportActionItemFragment
key={`person-${props.action.sequenceNumber}-${index}`}
key={`person-${props.action.reportActionID}-${index}`}
fragment={fragment}
tooltipText={props.action.actorEmail}
isAttachment={props.action.isAttachment}
Expand Down
19 changes: 13 additions & 6 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ReportActionsList extends React.Component {
* @return {String}
*/
keyExtractor(item) {
return `${item.action.clientID}${item.action.reportActionID}${item.action.sequenceNumber}`;
return `${item.action.clientID}${item.action.reportActionID}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need the clientID if we are switching to reportActionID and there will only ever be one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, we don't need clientID because we're assuming that reportActionID is random enough to be universally unique

}

/**
Expand Down Expand Up @@ -151,15 +151,22 @@ class ReportActionsList extends React.Component {
* higher z-index than the one below it. This prevents issues where the ReportActionContextMenu overlapping between
* rows is hidden beneath other rows.
*
* @param {Object} index - The ReportAction item in the FlatList.
* @param {Object|Array} style – The default styles of the CellRendererComponent provided by the CellRenderer.
* @param {Object} cellData
* @param {Object} cellData.item - The ReportAction item in the FlatList.
* @param {Number} cellData.index – The index of the item in the FlatList
* @param {Object|Array} cellData.style – The default styles of the CellRendererComponent provided by the CellRenderer.
* @param {Object} props – All the other Props provided to the CellRendererComponent by default.
* @returns {React.Component}
* @returns {JSX.Element}
*/
renderCell({item, style, ...props}) {
renderCell({
item,
index,
style,
...props
}) {
const cellStyle = [
style,
{zIndex: item.action.sequenceNumber},
{zIndex: index},
];
// eslint-disable-next-line react/jsx-props-no-spreading
return <View style={cellStyle} {...props} />;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/IOUTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class IOUTransactions extends Component {
chatReportID={this.props.chatReportID}
iouReportID={this.props.iouReportID}
action={reportAction}
key={reportAction.sequenceNumber}
key={reportAction.reportActionID}
canBeRejected={canBeRejected}
rejectButtonType={isCurrentUserTransactionCreator ? CONST.IOU.REPORT_ACTION_TYPE.CANCEL : CONST.IOU.REPORT_ACTION_TYPE.DECLINE}
/>
Expand Down