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 20759] Remove the *New* notifiers just as the deletion starts. #21557

Merged
merged 10 commits into from
Jul 3, 2023
18 changes: 18 additions & 0 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import lodashCloneDeep from 'lodash/cloneDeep';
import * as Report from '../../../libs/actions/Report';
import reportActionPropTypes from './reportActionPropTypes';
import Visibility from '../../../libs/Visibility';
Expand Down Expand Up @@ -218,6 +219,23 @@ class ReportActionsView extends React.Component {
});
}

// If the last unread message was deleted, remove the *New* green marker and the *New Messages* notification at scroll just as the deletion starts.
if (
ReportUtils.isUnread(this.props.report) &&
this.props.reportActions.length > 0 &&
this.props.reportActions[0].pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
!this.props.network.isOffline
) {
const reportActionsWithoutPendingOne = lodashCloneDeep(this.props.reportActions);
reportActionsWithoutPendingOne.shift();
const newMarkerReportActionID = ReportUtils.getNewMarkerReportActionID(this.props.report, reportActionsWithoutPendingOne);
if (newMarkerReportActionID !== this.state.newMarkerReportActionID) {
this.setState({
newMarkerReportActionID: newMarkerReportActionID,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
newMarkerReportActionID: newMarkerReportActionID,
newMarkerReportActionID,

Fix the lint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mollfpr Thanks! Fixed lint issue & merged main again.

});
}
}

// Checks to see if a report comment has been manually "marked as unread". All other times when the lastReadTime
// changes it will be because we marked the entire report as read.
const didManuallyMarkReportAsUnread = prevProps.report.lastReadTime !== this.props.report.lastReadTime && ReportUtils.isUnread(this.props.report);
Expand Down