From 3fec39feecfcd660dc9067cbb4d6130f614e47b7 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 24 May 2024 08:14:30 +0700 Subject: [PATCH 1/4] fix Unread message marker disappeared for next message --- src/libs/actions/Report.ts | 6 ++++-- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b0918391f432..cb0f47e98c26 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1139,7 +1139,7 @@ function expandURLPreview(reportID: string, reportActionID: string) { } /** Marks the new report actions as read */ -function readNewestAction(reportID: string) { +function readNewestAction(reportID: string, shouldResetUnread = false) { const lastReadTime = DateUtils.getDBTime(); const optimisticData: OnyxUpdate[] = [ @@ -1158,7 +1158,9 @@ function readNewestAction(reportID: string) { }; API.write(WRITE_COMMANDS.READ_NEWEST_ACTION, parameters, {optimisticData}); - DeviceEventEmitter.emit(`readNewestAction_${reportID}`, lastReadTime); + if (shouldResetUnread) { + DeviceEventEmitter.emit(`readNewestAction_${reportID}`, lastReadTime); + } } /** diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 105eadffd436..3dd8c31aae66 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -214,7 +214,7 @@ const ContextMenuActions: ContextMenuAction[] = [ shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => type === CONST.CONTEXT_MENU_TYPES.REPORT && isUnreadChat, onPress: (closePopover, {reportID}) => { - Report.readNewestAction(reportID); + Report.readNewestAction(reportID, true); if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); } From 3a3e436c0755169b192b6f4c94e0c52421508ff8 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 31 May 2024 18:29:28 +0700 Subject: [PATCH 2/4] fix rename param to shouldResetUnreadMarker --- src/libs/actions/Report.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 2c51a886be8e..a39750d18c14 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1161,7 +1161,7 @@ function expandURLPreview(reportID: string, reportActionID: string) { } /** Marks the new report actions as read */ -function readNewestAction(reportID: string, shouldResetUnread = false) { +function readNewestAction(reportID: string, shouldResetUnreadMarker = false) { const lastReadTime = DateUtils.getDBTime(); const optimisticData: OnyxUpdate[] = [ @@ -1180,7 +1180,7 @@ function readNewestAction(reportID: string, shouldResetUnread = false) { }; API.write(WRITE_COMMANDS.READ_NEWEST_ACTION, parameters, {optimisticData}); - if (shouldResetUnread) { + if (shouldResetUnreadMarker) { DeviceEventEmitter.emit(`readNewestAction_${reportID}`, lastReadTime); } } From 7c2cdab6d3455f936ff66ac3ed56869d3446aa26 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 31 May 2024 18:34:23 +0700 Subject: [PATCH 3/4] fix comment --- src/libs/actions/Report.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index a39750d18c14..f48d083acb73 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1160,7 +1160,10 @@ function expandURLPreview(reportID: string, reportActionID: string) { API.read(READ_COMMANDS.EXPAND_URL_PREVIEW, parameters); } -/** Marks the new report actions as read */ +/** Marks the new report actions as read + * + * @param shouldResetUnreadMarker Should we reset unread indicator + */ function readNewestAction(reportID: string, shouldResetUnreadMarker = false) { const lastReadTime = DateUtils.getDBTime(); From 961e22793c76f8801fee6cce22cc8bdb4e8a5d86 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 4 Jun 2024 02:28:59 +0700 Subject: [PATCH 4/4] fix add comment --- src/libs/actions/Report.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index f48d083acb73..ed6c1b20cdfc 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1161,8 +1161,8 @@ function expandURLPreview(reportID: string, reportActionID: string) { } /** Marks the new report actions as read - * - * @param shouldResetUnreadMarker Should we reset unread indicator + * @param shouldResetUnreadMarker Indicates whether the unread indicator should be reset. + * Currently, the unread indicator needs to be reset only when users mark a report as read. */ function readNewestAction(reportID: string, shouldResetUnreadMarker = false) { const lastReadTime = DateUtils.getDBTime();