Skip to content

Commit

Permalink
fix: encapsulate unread report logic into getUnreadReportsForUnreadIn…
Browse files Browse the repository at this point in the history
…dicator function
  • Loading branch information
allroundexperts committed Jan 14, 2024
1 parent d30bda4 commit 8c3c4e2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/libs/UnreadIndicatorUpdater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ import updateUnread from './updateUnread';

let allReports: OnyxCollection<Report> = {};

const triggerUnreadUpdate = () => {
const currentReportID = navigationRef.isReady() ? Navigation.getTopmostReportId() : '';

// We want to keep notification count consistent with what can be accessed from the LHN list
const unreadReports = Object.values(allReports ?? {}).filter(
export default function getUnreadReportsForUnreadIndicator(currentReportID: string) {
return Object.values(allReports ?? {}).filter(
(report) =>
ReportUtils.isUnread(report) &&
ReportUtils.shouldReportBeInOptionList(report, currentReportID ?? '', false, [], {}) &&
report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
);
}

const triggerUnreadUpdate = () => {
const currentReportID = navigationRef.isReady() ? Navigation.getTopmostReportId() ?? '' : '';

// We want to keep notification count consistent with what can be accessed from the LHN list
const unreadReports = getUnreadReportsForUnreadIndicator(currentReportID);
updateUnread(unreadReports.length);
};

Expand Down

0 comments on commit 8c3c4e2

Please sign in to comment.