From 630f9e44af7ef52ea737f76f55e2ae2845bb029c Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 7 May 2024 17:41:24 +0800 Subject: [PATCH 1/2] remove unused onyx data --- src/components/AttachmentModal.tsx | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index ab322aa1bd91..f697142c556e 100644 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -51,15 +51,6 @@ import SafeAreaConsumer from './SafeAreaConsumer'; type AttachmentModalOnyxProps = { /** The transaction associated with the receipt attachment, if any */ transaction: OnyxEntry; - - /** The report associated with the receipt attachment, if any */ - parentReport: OnyxEntry; - - /** The policy associated with the receipt attachment, if any */ - policy: OnyxEntry; - - /** The list of report actions associated with the receipt attachment, if any */ - parentReportActions: OnyxEntry; }; type ImagePickerResponse = { @@ -157,10 +148,7 @@ function AttachmentModal({ isWorkspaceAvatar = false, maybeIcon = false, transaction, - parentReport, - parentReportActions, headerTitle, - policy, children, fallbackSource, canEditReceipt = false, @@ -413,7 +401,7 @@ function AttachmentModal({ const sourceForAttachmentView = sourceState || source; const threeDotsMenuItems = useMemo(() => { - if (!isReceiptAttachment || !parentReport || !parentReportActions) { + if (!isReceiptAttachment) { return []; } @@ -454,7 +442,7 @@ function AttachmentModal({ } return menuItems; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isReceiptAttachment, parentReport, parentReportActions, policy, transaction, file, sourceState, iouType]); + }, [isReceiptAttachment, transaction, file, sourceState, iouType]); // There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment. // props.isReceiptAttachment will be null until its certain what the file is, in which case it will then be true|false. @@ -621,16 +609,6 @@ export default withOnyx({ }, initWithStoredValues: false, }, - parentReport: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, - }, - policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, - }, - parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, - canEvict: false, - }, })(memo(AttachmentModal)); export type {Attachment, FileObject, ImagePickerResponse}; From 83dc6221562c57788a376a15e24ef2f99aa43c89 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 7 May 2024 17:41:41 +0800 Subject: [PATCH 2/2] set initial value so it render faster --- .../report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 07de62b1eabd..11651d0435b7 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -330,5 +330,6 @@ AttachmentPickerWithMenuItems.displayName = 'AttachmentPickerWithMenuItems'; export default withOnyx({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, + initialValue: {} as OnyxTypes.Policy, }, })(AttachmentPickerWithMenuItems);