Skip to content

Commit

Permalink
Merge pull request #6978 from K4tsuki/last_navigation
Browse files Browse the repository at this point in the history
Allow App to Navigate to Last Visited Room On visiting with HOME url
  • Loading branch information
marcaaron authored Jan 11, 2022
2 parents 0d1ec3d + b7e77f7 commit 913bd46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,11 +1267,6 @@ function updateLastReadActionID(reportID, sequenceNumber) {
// (sequenceNumber - 1) || reportMaxSequenceNumbers[reportID] because the first expression results in 0 which is falsy.
const lastReadSequenceNumber = _.isNumber(sequenceNumber) ? (sequenceNumber - 1) : reportMaxSequenceNumbers[reportID];

// We call this method in many cases where there's nothing to update because we already updated it, so we avoid
// doing an unnecessary server call if the last read is the same one we had already
if (lastReadSequenceNumbers[reportID] === lastReadSequenceNumber) {
return;
}
setLocalLastRead(reportID, lastReadSequenceNumber);

// Mark the report as not having any unread items
Expand Down
13 changes: 5 additions & 8 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ReportActionsView extends React.Component {

this.renderItem = this.renderItem.bind(this);
this.renderCell = this.renderCell.bind(this);
this.scrollToListBottom = this.scrollToListBottom.bind(this);
this.scrollToBottomAndUpdateLastRead = this.scrollToBottomAndUpdateLastRead.bind(this);
this.onVisibilityChange = this.onVisibilityChange.bind(this);
this.recordTimeToMeasureItemLayout = this.recordTimeToMeasureItemLayout.bind(this);
this.loadMoreChats = this.loadMoreChats.bind(this);
Expand Down Expand Up @@ -143,8 +143,7 @@ class ReportActionsView extends React.Component {
if (!ReportActionComposeFocusManager.isFocused()) {
return;
}

this.scrollToListBottom();
ReportScrollManager.scrollToBottom();
});

this.updateUnreadIndicatorPosition(this.props.report.unreadActionCount);
Expand Down Expand Up @@ -221,7 +220,7 @@ class ReportActionsView extends React.Component {
// leave the user positioned where they are now in the list.
const lastAction = CollectionUtils.lastItem(this.props.reportActions);
if (lastAction && (lastAction.actorEmail === this.props.session.email)) {
this.scrollToListBottom();
ReportScrollManager.scrollToBottom();
}

if (lodashGet(lastAction, 'actorEmail', '') !== lodashGet(this.props.session, 'email', '')) {
Expand Down Expand Up @@ -331,7 +330,6 @@ class ReportActionsView extends React.Component {
return Math.ceil(availableHeight / minimumReportActionHeight);
}


/**
* Updates and sorts the report actions by sequence number
*
Expand Down Expand Up @@ -394,7 +392,7 @@ class ReportActionsView extends React.Component {
* items have been rendered. If the number of actions has changed since it was last rendered, then
* scroll the list to the end. As a report can contain non-message actions, we should confirm that list data exists.
*/
scrollToListBottom() {
scrollToBottomAndUpdateLastRead() {
ReportScrollManager.scrollToBottom();
Report.updateLastReadActionID(this.props.reportID);
}
Expand All @@ -411,7 +409,6 @@ class ReportActionsView extends React.Component {
Report.setNewMarkerPosition(this.props.reportID, oldestUnreadSequenceNumber);
}


/**
* Show/hide the new MarkerBadge when user is scrolling back/forth in the history of messages.
*/
Expand Down Expand Up @@ -571,7 +568,7 @@ class ReportActionsView extends React.Component {
<MarkerBadge
active={this.state.isMarkerActive}
count={this.state.localUnreadActionCount}
onClick={this.scrollToListBottom}
onClick={this.scrollToBottomAndUpdateLastRead}
onClose={this.hideMarker}
/>
<InvertedFlatList
Expand Down

0 comments on commit 913bd46

Please sign in to comment.