Skip to content

Commit

Permalink
Merge pull request #6459 from parasharrajat/newline
Browse files Browse the repository at this point in the history
fix: newline via updating the count first before marking the messages as read
  • Loading branch information
johnmlee101 authored Nov 24, 2021
2 parents 0aa9834 + 8b105f7 commit 03f1e76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ function updateReportWithNewAction(
reportID,

// Use updated lastReadSequenceNumber, value may have been modified by setLocalLastRead
unreadActionCount: newMaxSequenceNumber - (lastReadSequenceNumbers[reportID] || 0),
// Here deletedComments count does not include the new action being added. We can safely assume that newly received action is not deleted.
unreadActionCount: newMaxSequenceNumber - (lastReadSequenceNumbers[reportID] || 0) - ReportActions.getDeletedCommentsCount(reportID, lastReadSequenceNumbers[reportID] || 0),
maxSequenceNumber: reportAction.sequenceNumber,
};

Expand Down
17 changes: 9 additions & 8 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ class ReportActionsView extends React.Component {
this.scrollToListBottom();
});

this.updateUnreadIndicatorPosition(this.props.report.unreadActionCount);

// Only mark as read if the report is open
if (!this.props.isDrawerOpen) {
Report.updateLastReadActionID(this.props.reportID);
}

this.updateUnreadIndicatorPosition(this.props.report.unreadActionCount);
Report.fetchActions(this.props.reportID);
}

Expand Down Expand Up @@ -210,12 +211,6 @@ class ReportActionsView extends React.Component {
this.scrollToListBottom();
}

// When the last action changes, record the max action
// This will make the unread indicator go away if you receive comments in the same chat you're looking at
if (shouldRecordMaxAction) {
Report.updateLastReadActionID(this.props.reportID);
}

if (lodashGet(lastAction, 'actorEmail', '') !== lodashGet(this.props.session, 'email', '')) {
// Only update the unread count when MarkerBadge is visible
// Otherwise marker will be shown on scrolling up from the bottom even if user have read those messages
Expand All @@ -226,12 +221,18 @@ class ReportActionsView extends React.Component {
// show new MarkerBadge when there is a new message
this.toggleMarker();
}

// When the last action changes, record the max action
// This will make the unread indicator go away if you receive comments in the same chat you're looking at
if (shouldRecordMaxAction) {
Report.updateLastReadActionID(this.props.reportID);
}
} else if (shouldRecordMaxAction && (
prevProps.isDrawerOpen !== this.props.isDrawerOpen
|| prevProps.isSmallScreenWidth !== this.props.isSmallScreenWidth
)) {
Report.updateLastReadActionID(this.props.reportID);
this.updateUnreadIndicatorPosition(this.props.report.unreadActionCount);
Report.updateLastReadActionID(this.props.reportID);
}
}

Expand Down

0 comments on commit 03f1e76

Please sign in to comment.