From 6749e0abc0d041cfe0c4349c36a5982045cf1ae6 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 7 Dec 2023 22:39:15 +0700 Subject: [PATCH 01/10] fix: pdf not cached --- src/components/PDFView/index.native.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index b022823d215a..417106618c6d 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -11,6 +11,7 @@ import withThemeStyles, {withThemeStylesPropTypes} from '@components/withThemeSt import withWindowDimensions from '@components/withWindowDimensions'; import compose from '@libs/compose'; import * as StyleUtils from '@styles/StyleUtils'; +import * as CachedPDFPaths from '@userActions/CachedPDFPaths'; import CONST from '@src/CONST'; import PDFPasswordForm from './PDFPasswordForm'; import {defaultProps, propTypes as pdfViewPropTypes} from './pdfViewPropTypes'; @@ -118,7 +119,9 @@ class PDFView extends Component { * After the PDF is successfully loaded hide PDFPasswordForm and the loading * indicator. */ - finishPDFLoad() { + finishPDFLoad(_, path) { + console.log(path) + // CachedPDFPaths.save(path); this.setState({ shouldRequestPassword: false, shouldShowLoadingIndicator: false, @@ -155,7 +158,7 @@ class PDFView extends Component { fitPolicy={0} trustAllCerts={false} renderActivityIndicator={() => } - source={{uri: this.props.sourceURL}} + source={{uri: this.props.sourceURL, cache: true, expiration: 864000}} style={pdfStyles} onError={this.handleFailureToLoadPDF} password={this.state.password} From 0624e89a3f80065d08f2c271e78b505f779520e1 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 7 Dec 2023 22:40:08 +0700 Subject: [PATCH 02/10] fix lint --- src/components/PDFView/index.native.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index 417106618c6d..4f09906ad6fe 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -11,7 +11,6 @@ import withThemeStyles, {withThemeStylesPropTypes} from '@components/withThemeSt import withWindowDimensions from '@components/withWindowDimensions'; import compose from '@libs/compose'; import * as StyleUtils from '@styles/StyleUtils'; -import * as CachedPDFPaths from '@userActions/CachedPDFPaths'; import CONST from '@src/CONST'; import PDFPasswordForm from './PDFPasswordForm'; import {defaultProps, propTypes as pdfViewPropTypes} from './pdfViewPropTypes'; @@ -120,8 +119,6 @@ class PDFView extends Component { * indicator. */ finishPDFLoad(_, path) { - console.log(path) - // CachedPDFPaths.save(path); this.setState({ shouldRequestPassword: false, shouldShowLoadingIndicator: false, From 552592cd2ab1b75e54f10e4450dec427fe6dee02 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 7 Dec 2023 22:56:24 +0700 Subject: [PATCH 03/10] fix lint --- src/components/PDFView/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index 4f09906ad6fe..69a47ce82d9c 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -118,7 +118,7 @@ class PDFView extends Component { * After the PDF is successfully loaded hide PDFPasswordForm and the loading * indicator. */ - finishPDFLoad(_, path) { + finishPDFLoad() { this.setState({ shouldRequestPassword: false, shouldShowLoadingIndicator: false, From 35c7989f0a50998748982e6a4722ea2953616035 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 24 Jan 2024 18:41:13 +0700 Subject: [PATCH 04/10] remove cached file when delete comment --- src/ONYXKEYS.ts | 4 ++ .../AttachmentCarousel/CarouselItem.js | 1 + .../Attachments/AttachmentView/index.js | 17 +++++++- src/components/PDFView/index.native.js | 6 ++- src/libs/actions/CachedPDFPaths.ts | 39 +++++++++++++++++++ src/libs/actions/Report.ts | 2 + 6 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 src/libs/actions/CachedPDFPaths.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 9693c907a5fe..e8caede964e6 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -249,6 +249,9 @@ const ONYXKEYS = { /** Indicates whether an forced upgrade is required */ UPDATE_REQUIRED: 'updateRequired', + // Paths of PDF file that has been cached during one session + CACHED_PDF_PATHS: 'cachedPDFPaths', + /** Collection Keys */ COLLECTION: { DOWNLOAD: 'download_', @@ -446,6 +449,7 @@ type OnyxValues = { [ONYXKEYS.MAX_CANVAS_HEIGHT]: number; [ONYXKEYS.MAX_CANVAS_WIDTH]: number; [ONYXKEYS.UPDATE_REQUIRED]: boolean; + [ONYXKEYS.CACHED_PDF_PATHS]: Record; // Collections [ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download; diff --git a/src/components/Attachments/AttachmentCarousel/CarouselItem.js b/src/components/Attachments/AttachmentCarousel/CarouselItem.js index 5552f15320f3..53d72be49a47 100644 --- a/src/components/Attachments/AttachmentCarousel/CarouselItem.js +++ b/src/components/Attachments/AttachmentCarousel/CarouselItem.js @@ -110,6 +110,7 @@ function CarouselItem({item, index, activeIndex, isSingleItem, onPress}) { carouselActiveItemIndex={activeIndex} onPress={onPress} transactionID={item.transactionID} + reportActionID={item.reportActionID} /> diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index b0060afdb813..1a6f4d92c0e8 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -15,6 +15,7 @@ import useNetwork from '@hooks/useNetwork'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as CachedPDFPaths from '@libs/actions/CachedPDFPaths'; import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import compose from '@libs/compose'; import * as TransactionUtils from '@libs/TransactionUtils'; @@ -47,6 +48,9 @@ const propTypes = { /** The id of the transaction related to the attachment */ // eslint-disable-next-line react/no-unused-prop-types transactionID: PropTypes.string, + + /** The id of the report action related to the attachment */ + reportActionID: PropTypes.string, }; const defaultProps = { @@ -57,6 +61,7 @@ const defaultProps = { containerStyles: [], isWorkspaceAvatar: false, transactionID: '', + reportActionID: '', }; function AttachmentView({ @@ -79,6 +84,7 @@ function AttachmentView({ isWorkspaceAvatar, fallbackSource, transaction, + reportActionID, }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -127,6 +133,15 @@ function AttachmentView({ if ((_.isString(source) && Str.isPDF(source)) || (file && Str.isPDF(file.name || translate('attachmentView.unknownFilename')))) { const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source) : source; + const onPDFLoadComplete = (path) => { + if (isUsedInCarousel && reportActionID) { + CachedPDFPaths.add(reportActionID, path); + } + if (!loadComplete) { + setLoadComplete(true); + } + }; + // We need the following View component on android native // So that the event will propagate properly and // the Password protected preview will be shown for pdf attachement we are about to send. @@ -143,7 +158,7 @@ function AttachmentView({ onPress={onPress} onScaleChanged={onScaleChanged} onToggleKeyboard={onToggleKeyboard} - onLoadComplete={() => !loadComplete && setLoadComplete(true)} + onLoadComplete={onPDFLoadComplete} errorLabelStyles={isUsedInAttachmentModal ? [styles.textLabel, styles.textLarge] : [styles.cursorAuto]} style={isUsedInAttachmentModal ? styles.imageModalPDF : styles.flex1} isUsedInCarousel={isUsedInCarousel} diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index cbe7f0e4608e..08f2eb2c6984 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -118,14 +118,16 @@ class PDFView extends Component { /** * After the PDF is successfully loaded hide PDFPasswordForm and the loading * indicator. + * @param {Number} numberOfPages + * @param {Number} path - Path to cache location */ - finishPDFLoad() { + finishPDFLoad(numberOfPages, path) { this.setState({ shouldRequestPassword: false, shouldShowLoadingIndicator: false, successToLoadPDF: true, }); - this.props.onLoadComplete(); + this.props.onLoadComplete(path); } renderPDFView() { diff --git a/src/libs/actions/CachedPDFPaths.ts b/src/libs/actions/CachedPDFPaths.ts new file mode 100644 index 000000000000..28626dc34856 --- /dev/null +++ b/src/libs/actions/CachedPDFPaths.ts @@ -0,0 +1,39 @@ +import {exists, unlink} from 'react-native-fs'; +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; + +let pdfPaths: Record = {}; +Onyx.connect({ + key: ONYXKEYS.CACHED_PDF_PATHS, + callback: (val) => { + pdfPaths = val ?? {}; + }, +}); + +function add(reportActionID: string, path: string): Promise { + return Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: path}); +} + +function clear(path: string): Promise { + if (!path) { + return Promise.resolve(); + } + return new Promise((resolve) => { + exists(path).then((exist) => { + if (!exist) { + resolve(); + } + return unlink(path); + }); + }); +} + +function clearByKey(reportActionID: string) { + clear(pdfPaths[reportActionID] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: null})); +} + +function clearAll() { + Promise.all(Object.values(pdfPaths).map(clear)).then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {})); +} + +export {add, clearByKey, clearAll}; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 228b88d194ba..753831470c66 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -40,6 +40,7 @@ import type {Message, ReportActionBase, ReportActions} from '@src/types/onyx/Rep import type ReportAction from '@src/types/onyx/ReportAction'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import * as CachedPDFPaths from './CachedPDFPaths'; import * as Modal from './Modal'; import * as Session from './Session'; import * as Welcome from './Welcome'; @@ -1223,6 +1224,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { reportActionID, }; + CachedPDFPaths.clearByKey(reportActionID); API.write('DeleteComment', parameters, {optimisticData, successData, failureData}); } From 6981075dff4b466e784ee280878d6b39eb35a1c4 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 26 Jan 2024 16:07:20 +0700 Subject: [PATCH 05/10] resolve comments --- src/libs/actions/CachedPDFPaths.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/actions/CachedPDFPaths.ts b/src/libs/actions/CachedPDFPaths.ts index 28626dc34856..4eefb9a7982e 100644 --- a/src/libs/actions/CachedPDFPaths.ts +++ b/src/libs/actions/CachedPDFPaths.ts @@ -2,6 +2,10 @@ import {exists, unlink} from 'react-native-fs'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; +/* + * We need to save the paths of PDF files so we can delete them later. + * This is to remove the cached PDFs when an attachment is deleted or the user logs out. + */ let pdfPaths: Record = {}; Onyx.connect({ key: ONYXKEYS.CACHED_PDF_PATHS, @@ -11,6 +15,9 @@ Onyx.connect({ }); function add(reportActionID: string, path: string): Promise { + if (pdfPaths[reportActionID]) { + return Promise.resolve(); + } return Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: path}); } From 937946954bcce86a8af2b7b9eeca12336e155635 Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 5 Feb 2024 22:52:12 +0700 Subject: [PATCH 06/10] seperate platform logic --- .../index.native.ts} | 0 src/libs/actions/CachedPDFPaths/index.ts | 9 +++++++++ 2 files changed, 9 insertions(+) rename src/libs/actions/{CachedPDFPaths.ts => CachedPDFPaths/index.native.ts} (100%) create mode 100644 src/libs/actions/CachedPDFPaths/index.ts diff --git a/src/libs/actions/CachedPDFPaths.ts b/src/libs/actions/CachedPDFPaths/index.native.ts similarity index 100% rename from src/libs/actions/CachedPDFPaths.ts rename to src/libs/actions/CachedPDFPaths/index.native.ts diff --git a/src/libs/actions/CachedPDFPaths/index.ts b/src/libs/actions/CachedPDFPaths/index.ts new file mode 100644 index 000000000000..8c5c71df7a49 --- /dev/null +++ b/src/libs/actions/CachedPDFPaths/index.ts @@ -0,0 +1,9 @@ +function add(reportActionID: string, path: string): Promise { + return Promise.resolve(); +} + +function clearByKey(reportActionID: string) {} + +function clearAll() {} + +export {add, clearByKey, clearAll}; From 6eb146a455a902b3c7fcad8fdd2c93362150a107 Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 5 Feb 2024 23:07:20 +0700 Subject: [PATCH 07/10] add types for CachedPDFPaths --- .../Attachments/AttachmentView/index.js | 2 +- src/libs/actions/CachedPDFPaths/index.native.ts | 17 +++++++++-------- src/libs/actions/CachedPDFPaths/index.ts | 10 +++++----- src/libs/actions/CachedPDFPaths/types.ts | 6 ++++++ 4 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 src/libs/actions/CachedPDFPaths/types.ts diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index 39f83820d207..cf8cc6f017d9 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -143,7 +143,7 @@ function AttachmentView({ const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source) : source; const onPDFLoadComplete = (path) => { - if (isUsedInCarousel && reportActionID) { + if (isUsedInCarousel && reportActionID && path) { CachedPDFPaths.add(reportActionID, path); } if (!loadComplete) { diff --git a/src/libs/actions/CachedPDFPaths/index.native.ts b/src/libs/actions/CachedPDFPaths/index.native.ts index 4eefb9a7982e..6c4456f7a528 100644 --- a/src/libs/actions/CachedPDFPaths/index.native.ts +++ b/src/libs/actions/CachedPDFPaths/index.native.ts @@ -1,6 +1,7 @@ import {exists, unlink} from 'react-native-fs'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {Add, Clear, ClearAll, ClearByKey} from './types'; /* * We need to save the paths of PDF files so we can delete them later. @@ -14,14 +15,14 @@ Onyx.connect({ }, }); -function add(reportActionID: string, path: string): Promise { +const add: Add = (reportActionID: string, path: string) => { if (pdfPaths[reportActionID]) { return Promise.resolve(); } return Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: path}); -} +}; -function clear(path: string): Promise { +const clear: Clear = (path: string) => { if (!path) { return Promise.resolve(); } @@ -33,14 +34,14 @@ function clear(path: string): Promise { return unlink(path); }); }); -} +}; -function clearByKey(reportActionID: string) { +const clearByKey: ClearByKey = (reportActionID: string) => { clear(pdfPaths[reportActionID] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: null})); -} +}; -function clearAll() { +const clearAll: ClearAll = () => { Promise.all(Object.values(pdfPaths).map(clear)).then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {})); -} +}; export {add, clearByKey, clearAll}; diff --git a/src/libs/actions/CachedPDFPaths/index.ts b/src/libs/actions/CachedPDFPaths/index.ts index 8c5c71df7a49..3cac21bf3c25 100644 --- a/src/libs/actions/CachedPDFPaths/index.ts +++ b/src/libs/actions/CachedPDFPaths/index.ts @@ -1,9 +1,9 @@ -function add(reportActionID: string, path: string): Promise { - return Promise.resolve(); -} +import type {Add, ClearAll, ClearByKey} from './types'; -function clearByKey(reportActionID: string) {} +const add: Add = () => Promise.resolve(); -function clearAll() {} +const clearByKey: ClearByKey = () => {}; + +const clearAll: ClearAll = () => {}; export {add, clearByKey, clearAll}; diff --git a/src/libs/actions/CachedPDFPaths/types.ts b/src/libs/actions/CachedPDFPaths/types.ts new file mode 100644 index 000000000000..8c4843aaeaec --- /dev/null +++ b/src/libs/actions/CachedPDFPaths/types.ts @@ -0,0 +1,6 @@ +type Add = (reportActionID: string, path: string) => Promise; +type Clear = (path: string) => Promise; +type ClearAll = () => void; +type ClearByKey = (reportActionID: string) => void; + +export type {Add, Clear, ClearAll, ClearByKey}; From 55884df73116a71ed4ef78645a907f5ece5c872a Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 24 Feb 2024 06:14:50 +0700 Subject: [PATCH 08/10] fix lint --- src/components/PDFView/index.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index f47aeafd5316..f5a74011b6cd 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -104,8 +104,8 @@ function PDFView({onToggleKeyboard, onLoadComplete, fileName, onPress, isFocused /** * After the PDF is successfully loaded hide PDFPasswordForm and the loading * indicator. - * @param numberOfPages - * @param path - Path to cache location + * @param {Number} numberOfPages + * @param {Number} path - Path to cache location */ const finishPDFLoad = (numberOfPages, path) => { setShouldRequestPassword(false); From f7ed37e02855d0d3c8d3503694730b329287c974 Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 26 Feb 2024 17:15:21 +0700 Subject: [PATCH 09/10] remove redundant condition --- src/components/Attachments/AttachmentView/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index 68f41e1e51c3..e3c363c2f936 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -160,7 +160,7 @@ function AttachmentView({ const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source) : source; const onPDFLoadComplete = (path) => { - if (isUsedInCarousel && reportActionID && path) { + if (reportActionID && path) { CachedPDFPaths.add(reportActionID, path); } if (!loadComplete) { From abd53473a1e76f6433ee786462ec5840e4d2e57c Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 26 Feb 2024 17:24:10 +0700 Subject: [PATCH 10/10] delete cache for transaction receipt --- src/components/Attachments/AttachmentView/index.js | 4 ++-- src/libs/actions/CachedPDFPaths/index.native.ts | 10 +++++----- src/libs/actions/CachedPDFPaths/types.ts | 4 ++-- src/libs/actions/IOU.ts | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index e3c363c2f936..0b402e2da4ff 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -160,8 +160,8 @@ function AttachmentView({ const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source) : source; const onPDFLoadComplete = (path) => { - if (reportActionID && path) { - CachedPDFPaths.add(reportActionID, path); + if (path && (transaction.transactionID || reportActionID)) { + CachedPDFPaths.add(transaction.transactionID || reportActionID, path); } if (!loadComplete) { setLoadComplete(true); diff --git a/src/libs/actions/CachedPDFPaths/index.native.ts b/src/libs/actions/CachedPDFPaths/index.native.ts index 6c4456f7a528..09203995e9a1 100644 --- a/src/libs/actions/CachedPDFPaths/index.native.ts +++ b/src/libs/actions/CachedPDFPaths/index.native.ts @@ -15,11 +15,11 @@ Onyx.connect({ }, }); -const add: Add = (reportActionID: string, path: string) => { - if (pdfPaths[reportActionID]) { +const add: Add = (id: string, path: string) => { + if (pdfPaths[id]) { return Promise.resolve(); } - return Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: path}); + return Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[id]: path}); }; const clear: Clear = (path: string) => { @@ -36,8 +36,8 @@ const clear: Clear = (path: string) => { }); }; -const clearByKey: ClearByKey = (reportActionID: string) => { - clear(pdfPaths[reportActionID] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[reportActionID]: null})); +const clearByKey: ClearByKey = (id: string) => { + clear(pdfPaths[id] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[id]: null})); }; const clearAll: ClearAll = () => { diff --git a/src/libs/actions/CachedPDFPaths/types.ts b/src/libs/actions/CachedPDFPaths/types.ts index 8c4843aaeaec..98b768c4645e 100644 --- a/src/libs/actions/CachedPDFPaths/types.ts +++ b/src/libs/actions/CachedPDFPaths/types.ts @@ -1,6 +1,6 @@ -type Add = (reportActionID: string, path: string) => Promise; +type Add = (id: string, path: string) => Promise; type Clear = (path: string) => Promise; type ClearAll = () => void; -type ClearByKey = (reportActionID: string) => void; +type ClearByKey = (id: string) => void; export type {Add, Clear, ClearAll, ClearByKey}; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 37308c73e724..e8d1e43fb51b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -57,6 +57,7 @@ import type {OnyxData} from '@src/types/onyx/Request'; import type {Comment, Receipt, ReceiptSource, TaxRate, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import * as CachedPDFPaths from './CachedPDFPaths'; import * as Policy from './Policy'; import * as Report from './Report'; @@ -3139,6 +3140,7 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor // STEP 6: Make the API request API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData}); + CachedPDFPaths.clearByKey(transactionID); // STEP 7: Navigate the user depending on which page they are on and which resources were deleted if (iouReport && isSingleTransactionView && shouldDeleteTransactionThread && !shouldDeleteIOUReport) {