Skip to content

Commit

Permalink
fix: unread logic
Browse files Browse the repository at this point in the history
  • Loading branch information
allroundexperts committed Oct 21, 2023
1 parent ad8b9ff commit b0c9b95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,15 @@ function buildTransactionThread(reportAction, moneyRequestReportID) {
);
}

/**
* @param {Object} report
* @returns {Boolean}
*/
function isEmptyReport(report) {
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
return !report.lastMessageText && !report.lastMessageTranslationKey && !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey;
}

/**
* @param {Object} report
* @returns {Boolean}
Expand Down Expand Up @@ -4000,6 +4009,7 @@ export {
navigateToDetailsPage,
generateReportID,
hasReportNameError,
isEmptyReport,
isUnread,
isUnreadWithMention,
buildOptimisticWorkspaceChats,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/UnreadIndicatorUpdater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (reportsFromOnyx) => {
const unreadReports = _.filter(reportsFromOnyx, ReportUtils.isUnread);
const unreadReports = _.filter(reportsFromOnyx, (report) => ReportUtils.unread(report) && ReportUtils.isEmptyReport(report));
updateUnread(_.size(unreadReports));
},
});

0 comments on commit b0c9b95

Please sign in to comment.