Skip to content

Commit

Permalink
Merge pull request #2699 from Expensify/alberto-removeTimer
Browse files Browse the repository at this point in the history
Mark all actions as read immediately after the chat becomes active/visible
  • Loading branch information
MonilBhavsar authored May 7, 2021
2 parents e0c24d2 + 87d48f2 commit 2f544a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ class ReportActionsView extends React.Component {
this.scrollToListBottom = this.scrollToListBottom.bind(this);
this.onVisibilityChange = this.onVisibilityChange.bind(this);
this.loadMoreChats = this.loadMoreChats.bind(this);
this.startRecordMaxActionTimer = this.startRecordMaxActionTimer.bind(this);
this.sortedReportActions = [];
this.timers = [];

this.state = {
isLoadingMoreChats: false,
Expand Down Expand Up @@ -167,10 +165,10 @@ class ReportActionsView extends React.Component {
this.scrollToListBottom();
}

// When the last action changes, wait three seconds, then record the max action
// 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) {
this.startRecordMaxActionTimer();
updateLastReadActionID(this.props.reportID);
}
}

Expand All @@ -180,7 +178,7 @@ class ReportActionsView extends React.Component {
prevProps.isDrawerOpen !== this.props.isDrawerOpen
|| prevProps.isSmallScreenWidth !== this.props.isSmallScreenWidth
)) {
this.startRecordMaxActionTimer();
updateLastReadActionID(this.props.reportID);
}
}

Expand All @@ -191,7 +189,6 @@ class ReportActionsView extends React.Component {

AppState.removeEventListener('change', this.onVisibilityChange);

_.each(this.timers, timer => clearTimeout(timer));
unsubscribeFromReportChannel(this.props.reportID);
}

Expand All @@ -200,19 +197,10 @@ class ReportActionsView extends React.Component {
*/
onVisibilityChange() {
if (Visibility.isVisible()) {
this.startRecordMaxActionTimer();
updateLastReadActionID(this.props.reportID);
}
}

/**
* Set a timer for recording the max action
*
* @memberof ReportActionsView
*/
startRecordMaxActionTimer() {
this.timers.push(setTimeout(() => updateLastReadActionID(this.props.reportID), 3000));
}

/**
* Retrieves the next set of report actions for the chat once we are nearing the end of what we are currently
* displaying.
Expand Down
Empty file.

0 comments on commit 2f544a6

Please sign in to comment.