From a2cfd544cc71812b8cc1d91ddc675140cb1852f8 Mon Sep 17 00:00:00 2001 From: dominictb Date: Tue, 18 Jun 2024 01:51:09 +0700 Subject: [PATCH] chore: update expensify-common 2.0.17 --- package-lock.json | 11 +++++------ package.json | 2 +- src/libs/OnyxAwareParser.ts | 18 ++++++++++++++---- src/libs/actions/Report.ts | 1 + .../report/ReportActionItemMessageEdit.tsx | 6 ++---- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1c8cee95d34..36156f2b2ca6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -60,7 +60,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "^2.0.12", + "expensify-common": "2.0.17", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", @@ -20769,9 +20769,9 @@ } }, "node_modules/expensify-common": { - "version": "2.0.12", - "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.12.tgz", - "integrity": "sha512-idIm9mAGDX1qyfA2Ky/1ZJZVMbGydtpIdwl6zl1Yc7FO11IGvAYLh2cH9VsQk98AapRTiJu7QUaRWLLGDaHIcQ==", + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.17.tgz", + "integrity": "sha512-W7xO10/bYF/p0/cUOtzejXJDiLCB/U6JTXVltzOE70xjGgzTSyRotPkEtEItHTvXOS2Wz8jJ262nrGfFMpfisA==", "dependencies": { "awesome-phonenumber": "^5.4.0", "classnames": "2.5.0", @@ -20785,8 +20785,7 @@ "react-dom": "16.12.0", "semver": "^7.6.0", "simply-deferred": "git+https://github.com/Expensify/simply-deferred.git#77a08a95754660c7bd6e0b6979fdf84e8e831bf5", - "ua-parser-js": "^1.0.37", - "underscore": "1.13.6" + "ua-parser-js": "^1.0.37" } }, "node_modules/expensify-common/node_modules/react": { diff --git a/package.json b/package.json index dd594ddbc8c2..f1030b9420c6 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "^2.0.12", + "expensify-common": "2.0.17", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", diff --git a/src/libs/OnyxAwareParser.ts b/src/libs/OnyxAwareParser.ts index a202118bdf5f..c058775341c2 100644 --- a/src/libs/OnyxAwareParser.ts +++ b/src/libs/OnyxAwareParser.ts @@ -31,12 +31,22 @@ Onyx.connect({ }, }); -function parseHtmlToMarkdown(html: string, reportIDToName?: Record, accountIDToName?: Record): string { - return parser.htmlToMarkdown(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap}); +function parseHtmlToMarkdown( + html: string, + reportIDToName?: Record, + accountIDToName?: Record, + cacheVideoAttributes?: (videoSource: string, videoAttrs: string) => void, +): string { + return parser.htmlToMarkdown(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap, cacheVideoAttributes}); } -function parseHtmlToText(html: string, reportIDToName?: Record, accountIDToName?: Record): string { - return parser.htmlToText(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap}); +function parseHtmlToText( + html: string, + reportIDToName?: Record, + accountIDToName?: Record, + cacheVideoAttributes?: (videoSource: string, videoAttrs: string) => void, +): string { + return parser.htmlToText(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap, cacheVideoAttributes}); } export {parseHtmlToMarkdown, parseHtmlToText}; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 1d42ac2d50c0..c8a8563c777f 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1450,6 +1450,7 @@ function removeLinksFromHtml(html: string, links: string[]): string { * * @param newCommentText text of the comment after editing. * @param originalCommentMarkdown original markdown of the comment before editing. + * @param videoAttributeCache cache of video attributes ([videoSource]: videoAttributes) */ function handleUserDeletedLinksInHtml(newCommentText: string, originalCommentMarkdown: string, videoAttributeCache?: Record): string { const parser = new ExpensiMark(); diff --git a/src/pages/home/report/ReportActionItemMessageEdit.tsx b/src/pages/home/report/ReportActionItemMessageEdit.tsx index 9fdaf95f86b4..49f889c7aa92 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.tsx +++ b/src/pages/home/report/ReportActionItemMessageEdit.tsx @@ -110,10 +110,8 @@ function ReportActionItemMessageEdit( useEffect(() => { draftMessageVideoAttributeCache.clear(); - const originalMessage = parseHtmlToMarkdown(action.message?.[0]?.html ?? '', undefined, undefined, { - cacheVideoAttributes: (videoSource, attrs) => { - draftMessageVideoAttributeCache.set(videoSource, attrs); - }, + const originalMessage = parseHtmlToMarkdown(action.message?.[0]?.html ?? '', undefined, undefined, (videoSource, attrs) => { + draftMessageVideoAttributeCache.set(videoSource, attrs); }); if (ReportActionsUtils.isDeletedAction(action) || !!(action.message && draftMessage === originalMessage) || !!(prevDraftMessage === draftMessage || isCommentPendingSaved.current)) { return;