From 103cacdd1f19db1def4b4c143897b30bbe75f0bf Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 25 Sep 2024 23:45:57 +0300 Subject: [PATCH 1/4] avoid double closeModal execution --- src/libs/actions/Modal.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/Modal.ts b/src/libs/actions/Modal.ts index 01ac832336ab..00853e9546d5 100644 --- a/src/libs/actions/Modal.ts +++ b/src/libs/actions/Modal.ts @@ -32,9 +32,11 @@ function closeTop() { } if (onModalClose) { closeModals[closeModals.length - 1](isNavigate); + closeModals.pop(); return; } closeModals[closeModals.length - 1](); + closeModals.pop(); } /** From 5bfaa7ec59d249396016b3ebee7351b08ac4adbc Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 25 Sep 2024 23:46:36 +0300 Subject: [PATCH 2/4] replace goBack with dismissModal --- src/pages/TransactionReceiptPage.tsx | 32 +++++++--------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/pages/TransactionReceiptPage.tsx b/src/pages/TransactionReceiptPage.tsx index 60f5ad4dbd86..495458c6b80f 100644 --- a/src/pages/TransactionReceiptPage.tsx +++ b/src/pages/TransactionReceiptPage.tsx @@ -1,7 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect} from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import AttachmentModal from '@components/AttachmentModal'; import Navigation from '@libs/Navigation/Navigation'; import type {AuthScreensParamList} from '@libs/Navigation/types'; @@ -13,19 +12,14 @@ import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import * as ReportActions from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Report, ReportMetadata, Transaction} from '@src/types/onyx'; -type TransactionReceiptOnyxProps = { - report: OnyxEntry; - transaction: OnyxEntry; - reportMetadata: OnyxEntry; -}; +type TransactionReceiptProps = StackScreenProps; -type TransactionReceiptProps = TransactionReceiptOnyxProps & StackScreenProps; - -function TransactionReceipt({transaction, report, reportMetadata = {isLoadingInitialReportActions: true}, route}: TransactionReceiptProps) { +function TransactionReceipt({route}: TransactionReceiptProps) { + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID ?? '-1'}`); + const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID ?? '-1'}`); + const [reportMetadata = {isLoadingInitialReportActions: true}] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${route.params.reportID ?? '-1'}`); const receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction); const imageSource = tryResolveUrlFromApiRoot(receiptURIs.image ?? ''); @@ -65,7 +59,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni originalFileName={receiptURIs?.filename} defaultOpen onModalClose={() => { - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(report?.reportID ?? '-1')); + Navigation.dismissModal(report?.reportID ?? '-1'); }} isLoading={!transaction && reportMetadata?.isLoadingInitialReportActions} shouldShowNotFoundPage={shouldShowNotFoundPage} @@ -75,14 +69,4 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni TransactionReceipt.displayName = 'TransactionReceipt'; -export default withOnyx({ - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID ?? '-1'}`, - }, - transaction: { - key: ({route}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID ?? '-1'}`, - }, - reportMetadata: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${route.params.reportID ?? '-1'}`, - }, -})(TransactionReceipt); +export default TransactionReceipt; From 6e85e5f21623cd72e42a31305574d6f0bf3b43e8 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 25 Sep 2024 23:48:23 +0300 Subject: [PATCH 3/4] revert the wrong fix --- src/pages/home/report/ReportAttachments.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/pages/home/report/ReportAttachments.tsx b/src/pages/home/report/ReportAttachments.tsx index 369d5cef6ee4..3168f8b84617 100644 --- a/src/pages/home/report/ReportAttachments.tsx +++ b/src/pages/home/report/ReportAttachments.tsx @@ -19,14 +19,6 @@ function ReportAttachments({route}: ReportAttachmentsProps) { const accountID = route.params.accountID; const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); - const hasDismissedModalRef = useRef(false); - - useEffect( - () => () => { - hasDismissedModalRef.current = false; - }, - [], - ); // In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource const source = Number(route.params.source) || route.params.source; @@ -48,10 +40,7 @@ function ReportAttachments({route}: ReportAttachmentsProps) { report={report} source={source} onModalClose={() => { - if (!hasDismissedModalRef.current) { - Navigation.dismissModal(); - hasDismissedModalRef.current = true; - } + Navigation.dismissModal(); // This enables Composer refocus when the attachments modal is closed by the browser navigation ComposerFocusManager.setReadyToFocus(); }} From 84776659ccfb67e6d534b54a59826c02a02ff791 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 25 Sep 2024 23:49:00 +0300 Subject: [PATCH 4/4] minor fix --- src/pages/home/report/ReportAttachments.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportAttachments.tsx b/src/pages/home/report/ReportAttachments.tsx index 3168f8b84617..1e16cfdddf4f 100644 --- a/src/pages/home/report/ReportAttachments.tsx +++ b/src/pages/home/report/ReportAttachments.tsx @@ -1,5 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useCallback, useEffect, useRef} from 'react'; +import React, {useCallback} from 'react'; import {useOnyx} from 'react-native-onyx'; import AttachmentModal from '@components/AttachmentModal'; import type {Attachment} from '@components/Attachments/types';