Skip to content

Commit

Permalink
replace local function for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
gedu committed Feb 23, 2023
1 parent 17dc211 commit f54539a
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ReportScreen extends React.Component {
this.dismissBanner = this.dismissBanner.bind(this);

// We need this.sortedAndFilteredReportActions to be set before this.state is initialized because the function to calculate the newMarkerReportActionID uses the sorted report actions
this.sortedAndFilteredReportActions = this.getSortedReportActionsForDisplay(props.reportActions);
this.sortedAndFilteredReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(props.reportActions);

this.state = {
skeletonViewContainerHeight: reportActionsListViewHeight,
Expand All @@ -129,7 +129,7 @@ class ReportScreen extends React.Component {

shouldComponentUpdate(nextProps) {
if (!_.isEqual(nextProps.reportActions, this.props.reportActions)) {
this.sortedAndFilteredReportActions = this.getSortedReportActionsForDisplay(nextProps.reportActions);
this.sortedAndFilteredReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(nextProps.reportActions);

return true;
}
Expand Down Expand Up @@ -201,29 +201,6 @@ class ReportScreen extends React.Component {
Report.addComment(getReportID(this.props.route), text);
}

/**
* @param {Object} reportActions
* @returns {Array}
*/
getSortedReportActionsForDisplay(reportActions) {
// HACK ALERT: We're temporarily filtering out any reportActions keyed by sequenceNumber
// to prevent bugs during the migration from sequenceNumber -> reportActionID
const filteredReportActions = _.filter(reportActions, (reportAction, key) => {
if (!reportAction) {
return false;
}

if (String(reportAction.sequenceNumber) === key) {
return false;
}

return true;
});

const sortedReportActions = ReportActionsUtils.getSortedReportActions(filteredReportActions, true);
return ReportActionsUtils.filterReportActionsForDisplay(sortedReportActions);
}

/**
* When false the ReportActionsView will completely unmount and we will show a loader until it returns true.
*
Expand Down

0 comments on commit f54539a

Please sign in to comment.