Repository navigation
[Phase 4] - Remove module-level reportAttributesDerivedValue in isEmptyReport() #100693
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
Changes from all commits
a39db3c
fea6618
3c74c72
1981a18
a24baed
2505434
01f2d82
42e0309
9cd9b11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ import Navigation, {navigationRef} from '@navigation/Navigation'; | |
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Report, ReportActions, ReportNameValuePairs, Session} from '@src/types/onyx'; | ||
| import type {Report, ReportActions, ReportAttributesDerivedValue, ReportNameValuePairs, Session} from '@src/types/onyx'; | ||
|
|
||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
|
|
||
|
|
@@ -65,6 +65,15 @@ Onyx.connectWithoutView({ | |
| }, | ||
| }); | ||
|
|
||
| let reportAttributesDerived: ReportAttributesDerivedValue['reports'] | undefined; | ||
| // This subscription is used to update the unread indicators count which is not linked to UI and it does not update any UI state. | ||
| Onyx.connectWithoutView({ | ||
|
Comment on lines
+68
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please leave a clear comment why its fine to use it here? thanks
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I done in a24baed and added comment explaining this subscription updates the unread indicator count, which is not linked to UI and doesn't update any UI state |
||
| key: ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, | ||
| callback: (value) => { | ||
| reportAttributesDerived = value?.reports; | ||
| }, | ||
| }); | ||
|
|
||
| function getUnreadReportsForUnreadIndicator(reports: OnyxCollection<Report>, currentReportID: string | undefined, draftComment: string | undefined) { | ||
| // Read the in-memory offline state directly since this is an imperative one-shot computation (reactivity is not needed here). | ||
| const isOffline = getIsOffline(); | ||
|
|
@@ -91,7 +100,9 @@ function getUnreadReportsForUnreadIndicator(reports: OnyxCollection<Report>, cur | |
| const oneTransactionThreadReportID = getOneTransactionThreadReportID(report, chatReport, allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`], isOffline); | ||
| const oneTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneTransactionThreadReportID}`]; | ||
|
|
||
| if (!ReportUtils.isUnread(report, oneTransactionThreadReport, isReportArchived)) { | ||
| const derivedIsEmptyReport = report?.reportID ? reportAttributesDerived?.[report.reportID]?.isEmpty : undefined; | ||
|
|
||
| if (!ReportUtils.isUnread(report, oneTransactionThreadReport, isReportArchived, derivedIsEmptyReport)) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -112,6 +123,7 @@ function getUnreadReportsForUnreadIndicator(reports: OnyxCollection<Report>, cur | |
| // TODO: Pass guideAccountIDs once callers are fully migrated — PR 33 (https://github.com/Expensify/App/issues/66413); hasExpensifyGuidesEmails falls back to allPersonalDetails | ||
| hasGuidesEmails: ReportUtils.isDefaultRoom(report) ? ReportUtils.hasExpensifyGuidesEmails(Object.keys(report?.participants ?? {}).map(Number), undefined) : false, | ||
| conciergeReportID, | ||
| derivedIsEmptyReport, | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.