Skip to content

Commit

Permalink
using lastMentionedTime to check if chat is unread
Browse files Browse the repository at this point in the history
  • Loading branch information
rlinoz committed Feb 9, 2024
1 parent 483724f commit b4811d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3578,7 +3578,10 @@ function isUnread(report: OnyxEntry<Report>): boolean {
// lastVisibleActionCreated and lastReadTime are both datetime strings and can be compared directly
const lastVisibleActionCreated = report.lastVisibleActionCreated ?? '';
const lastReadTime = report.lastReadTime ?? '';
return lastReadTime < lastVisibleActionCreated;
const lastMentionedTime = report.lastMentionedTime ?? '';

// If the user was mentioned and the comment got deleted the lastMentionedTime will be more recent than the lastVisibleActionCreated
return lastReadTime < lastVisibleActionCreated || lastReadTime < lastMentionedTime;
}

function isIOUOwnedByCurrentUser(report: OnyxEntry<Report>, allReportsDict: OnyxCollection<Report> = null): boolean {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function ReportScreen({
oldPolicyName: reportProp.oldPolicyName,
policyName: reportProp.policyName,
isOptimisticReport: reportProp.isOptimisticReport,
lastMentionedTime: reportProp.lastMentionedTime,
}),
[
reportProp.lastReadTime,
Expand Down Expand Up @@ -242,6 +243,7 @@ function ReportScreen({
reportProp.oldPolicyName,
reportProp.policyName,
reportProp.isOptimisticReport,
reportProp.lastMentionedTime,
],
);

Expand Down

0 comments on commit b4811d2

Please sign in to comment.