Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Unread message marker disappeared for next message #42568

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,11 @@ function expandURLPreview(reportID: string, reportActionID: string) {
API.read(READ_COMMANDS.EXPAND_URL_PREVIEW, parameters);
}

/** Marks the new report actions as read */
function readNewestAction(reportID: string) {
/** Marks the new report actions as read
* @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();

const optimisticData: OnyxUpdate[] = [
Expand All @@ -1180,7 +1183,9 @@ function readNewestAction(reportID: string) {
};

API.write(WRITE_COMMANDS.READ_NEWEST_ACTION, parameters, {optimisticData});
DeviceEventEmitter.emit(`readNewestAction_${reportID}`, lastReadTime);
if (shouldResetUnreadMarker) {
DeviceEventEmitter.emit(`readNewestAction_${reportID}`, lastReadTime);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,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);
}
Expand Down
Loading