From e635fd890290fe8b1fa470200d14c4c17d7338dd Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Thu, 9 Sep 2021 12:28:10 +0530 Subject: [PATCH] fix unread marking logic for mobile on visibility change --- src/libs/Visibility/index.native.js | 4 +++- src/pages/home/report/ReportActionsView.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/Visibility/index.native.js b/src/libs/Visibility/index.native.js index ba878d4ef7d0..5a2f1d74909f 100644 --- a/src/libs/Visibility/index.native.js +++ b/src/libs/Visibility/index.native.js @@ -1,10 +1,12 @@ // Mobile apps do not require this check for visibility as // they do not use the Notification lib. +import {AppState} from 'react-native'; + /** * @return {Boolean} */ -const isVisible = () => true; +const isVisible = () => AppState.currentState === 'active'; export default { isVisible, diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index cf944d4b196d..bc91c5def802 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -129,7 +129,12 @@ class ReportActionsView extends React.Component { this.scrollToListBottom(); } }); - updateLastReadActionID(this.props.reportID); + + // Only mark as read if the report is open + if (!this.props.isDrawerOpen) { + updateLastReadActionID(this.props.reportID); + } + this.updateUnreadIndicatorPosition(this.props.report.unreadActionCount); fetchActions(this.props.reportID); } @@ -229,7 +234,8 @@ class ReportActionsView extends React.Component { * Records the max action on app visibility change event. */ onVisibilityChange() { - if (Visibility.isVisible()) { + // only mark as read if visible AND report is open. + if (Visibility.isVisible() && !this.props.isDrawerOpen) { updateLastReadActionID(this.props.reportID); } }