Skip to content

Commit 7575e94

Browse files
puneetlathOSBotify
authored andcommitted
Merge pull request #46526 from ishpaul777/revert-45240-hur/fix-45228
Revert "fix: archived reports are unable to mark as read" (cherry picked from commit d6dda64)
1 parent 173b5e2 commit 7575e94

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/pages/home/report/ReportActionsList.tsx

+11-23
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ function ReportActionsList({
177177
const userActiveSince = useRef<string | null>(null);
178178
const lastMessageTime = useRef<string | null>(null);
179179

180-
const [isVisible, setIsVisible] = useState(Visibility.isVisible());
181-
const hasCalledReadNewestAction = useRef(false);
180+
const [isVisible, setIsVisible] = useState(false);
182181
const isFocused = useIsFocused();
183182

184183
useEffect(() => {
@@ -268,17 +267,13 @@ function ReportActionsList({
268267
if (!userActiveSince.current || report.reportID !== prevReportID) {
269268
return;
270269
}
271-
if (hasCalledReadNewestAction.current) {
272-
return;
273-
}
274270
if (ReportUtils.isUnread(report)) {
275271
// On desktop, when the notification center is displayed, Visibility.isVisible() will return false.
276272
// Currently, there's no programmatic way to dismiss the notification center panel.
277273
// To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification.
278274
const isFromNotification = route?.params?.referrer === CONST.REFERRER.NOTIFICATION;
279275
if ((Visibility.isVisible() || isFromNotification) && scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD) {
280276
Report.readNewestAction(report.reportID);
281-
hasCalledReadNewestAction.current = true;
282277
if (isFromNotification) {
283278
Navigation.setParams({referrer: undefined});
284279
}
@@ -529,10 +524,6 @@ function ReportActionsList({
529524
return;
530525
}
531526

532-
if (hasCalledReadNewestAction.current) {
533-
return;
534-
}
535-
536527
if (!isVisible || !isFocused) {
537528
if (!lastMessageTime.current) {
538529
lastMessageTime.current = sortedVisibleReportActions[0]?.created ?? '';
@@ -544,27 +535,24 @@ function ReportActionsList({
544535
// show marker based on report.lastReadTime
545536
const newMessageTimeReference = lastMessageTime.current && report.lastReadTime && lastMessageTime.current > report.lastReadTime ? userActiveSince.current : report.lastReadTime;
546537
lastMessageTime.current = null;
547-
const areSomeReportActionsUnread = sortedVisibleReportActions.some((reportAction) => {
548-
/**
549-
* The archived reports should not be marked as unread. So we are checking if the report is archived or not.
550-
* If the report is archived, we will mark the report as read.
551-
*/
552-
const isArchivedReport = ReportUtils.isArchivedRoom(report);
553-
const isUnread = isArchivedReport || (newMessageTimeReference && newMessageTimeReference < reportAction.created);
554-
return (
555-
isUnread && (ReportActionsUtils.isReportPreviewAction(reportAction) ? reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID()
556-
);
557-
});
558-
if (scrollingVerticalOffset.current >= MSG_VISIBLE_THRESHOLD || !areSomeReportActionsUnread) {
538+
if (
539+
scrollingVerticalOffset.current >= MSG_VISIBLE_THRESHOLD ||
540+
!sortedVisibleReportActions.some(
541+
(reportAction) =>
542+
newMessageTimeReference &&
543+
newMessageTimeReference < reportAction.created &&
544+
(ReportActionsUtils.isReportPreviewAction(reportAction) ? reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID(),
545+
)
546+
) {
559547
return;
560548
}
549+
561550
Report.readNewestAction(report.reportID);
562551
userActiveSince.current = DateUtils.getDBTime();
563552
lastReadTimeRef.current = newMessageTimeReference;
564553
setCurrentUnreadMarker(null);
565554
cacheUnreadMarkers.delete(report.reportID);
566555
calculateUnreadMarker();
567-
hasCalledReadNewestAction.current = true;
568556

569557
// This effect logic to `mark as read` will only run when the report focused has new messages and the App visibility
570558
// is changed to visible(meaning user switched to app/web, while user was previously using different tab or application).

0 commit comments

Comments
 (0)