From 2ff38ff66500298d6e5dbb883a6e56e9ed6377a5 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 18 Nov 2024 11:27:35 +0100 Subject: [PATCH] move isLoadingPrivateNotes key to reportMetadata_ --- src/libs/DebugUtils.ts | 1 - src/libs/actions/Report.ts | 6 +++--- src/pages/ReportDetailsPage.tsx | 4 ++-- .../home/report/withReportAndPrivateNotesOrNotFound.tsx | 6 +++--- src/types/form/DebugReportForm.ts | 2 -- src/types/onyx/Report.ts | 3 --- src/types/onyx/ReportMetadata.ts | 3 +++ src/types/utils/whitelistedReportKeys.ts | 1 - 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 2f0da08b194d..98dbbd4014a1 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -65,7 +65,6 @@ const REPORT_BOOLEAN_PROPERTIES: Array = [ 'isWaitingOnBankAccount', 'isCancelledIOU', 'isHidden', - 'isLoadingPrivateNotes', ] satisfies Array; const REPORT_DATE_PROPERTIES: Array = ['lastVisibleActionCreated', 'lastReadTime', 'lastMentionedTime', 'lastVisibleActionLastModified'] satisfies Array; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 32c0a40876d7..d5d6aee59a16 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3440,7 +3440,7 @@ function getReportPrivateNote(reportID: string | undefined) { const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, value: { isLoadingPrivateNotes: true, }, @@ -3450,7 +3450,7 @@ function getReportPrivateNote(reportID: string | undefined) { const successData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, value: { isLoadingPrivateNotes: false, }, @@ -3460,7 +3460,7 @@ function getReportPrivateNote(reportID: string | undefined) { const failureData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, value: { isLoadingPrivateNotes: false, }, diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 9e438f0549e2..19fd481e508f 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,7 +80,7 @@ const CASES = { type CaseID = ValueOf; -function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { +function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDetailsPageProps) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); const styles = useThemeStyles(); @@ -183,7 +183,7 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { // 1. HeaderView return CASES.DEFAULT; }, [isInvoiceReport, isMoneyRequestReport, isSingleTransactionView]); - const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined; + const isPrivateNotesFetchTriggered = reportMetadata?.isLoadingPrivateNotes !== undefined; const requestParentReportAction = useMemo(() => { // 2. MoneyReport case diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index 2fed275045bc..b27a2a2c9fb9 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -31,14 +31,14 @@ export default function (pageTitle: TranslationPaths) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); const [session] = useOnyx(ONYXKEYS.SESSION); - const {route, report} = props; + const {route, report, reportMetadata} = props; const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const accountID = ('accountID' in route.params && route.params.accountID) || ''; - const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined; + const isPrivateNotesFetchTriggered = reportMetadata?.isLoadingPrivateNotes !== undefined; const prevIsOffline = usePrevious(isOffline); const isReconnecting = prevIsOffline && !isOffline; const isOtherUserNote = !!accountID && Number(session?.accountID) !== Number(accountID); - const isPrivateNotesFetchFinished = isPrivateNotesFetchTriggered && !report.isLoadingPrivateNotes; + const isPrivateNotesFetchFinished = isPrivateNotesFetchTriggered && !reportMetadata.isLoadingPrivateNotes; const isPrivateNotesUndefined = accountID ? report?.privateNotes?.[Number(accountID)]?.note === undefined : isEmptyObject(report?.privateNotes); useEffect(() => { diff --git a/src/types/form/DebugReportForm.ts b/src/types/form/DebugReportForm.ts index c21ca6f2dc73..87f4f38ee329 100644 --- a/src/types/form/DebugReportForm.ts +++ b/src/types/form/DebugReportForm.ts @@ -11,7 +11,6 @@ const INPUT_IDS = { HAS_OUTSTANDING_CHILD_REQUEST: 'hasOutstandingChildRequest', HAS_OUTSTANDING_CHILD_TASK: 'hasOutstandingChildTask', IS_CANCELLED_IOU: 'isCancelledIOU', - IS_LOADING_PRIVATE_NOTES: 'isLoadingPrivateNotes', IS_OWN_POLICY_EXPENSE_CHAT: 'isOwnPolicyExpenseChat', IS_PINNED: 'isPinned', IS_WAITING_ON_BANK_ACCOUNT: 'isWaitingOnBankAccount', @@ -60,7 +59,6 @@ type DebugReportForm = Form< [INPUT_IDS.HAS_OUTSTANDING_CHILD_REQUEST]: boolean; [INPUT_IDS.HAS_OUTSTANDING_CHILD_TASK]: boolean; [INPUT_IDS.IS_CANCELLED_IOU]: boolean; - [INPUT_IDS.IS_LOADING_PRIVATE_NOTES]: boolean; [INPUT_IDS.IS_OWN_POLICY_EXPENSE_CHAT]: boolean; [INPUT_IDS.IS_PINNED]: boolean; [INPUT_IDS.IS_WAITING_ON_BANK_ACCOUNT]: boolean; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 1241556c8dbd..c2d8f7b21428 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -232,9 +232,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Collection of participant private notes, indexed by their accountID */ privateNotes?: Record; - /** Whether participants private notes are being currently loaded */ - isLoadingPrivateNotes?: boolean; - /** Pending members of the report */ pendingChatMembers?: PendingChatMember[]; diff --git a/src/types/onyx/ReportMetadata.ts b/src/types/onyx/ReportMetadata.ts index 65a6f153c51b..36c5aee1cb57 100644 --- a/src/types/onyx/ReportMetadata.ts +++ b/src/types/onyx/ReportMetadata.ts @@ -17,6 +17,9 @@ type ReportMetadata = { /** The time when user last visited the report */ lastVisitTime?: string; + + /** Whether participants private notes are being currently loaded */ + isLoadingPrivateNotes?: boolean; }; export default ReportMetadata; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 3c566c987526..07173c8bc073 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -61,7 +61,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< nonReimbursableTotal: unknown; isHidden: unknown; privateNotes: unknown; - isLoadingPrivateNotes: unknown; pendingChatMembers: unknown; transactionThreadReportID: unknown; fieldList: unknown;