diff --git a/package-lock.json b/package-lock.json index 0c7c6d2a11ce..bd84b362c019 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.17", + "expensify-common": "^2.0.12", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", @@ -20770,9 +20770,9 @@ } }, "node_modules/expensify-common": { - "version": "2.0.17", - "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.17.tgz", - "integrity": "sha512-W7xO10/bYF/p0/cUOtzejXJDiLCB/U6JTXVltzOE70xjGgzTSyRotPkEtEItHTvXOS2Wz8jJ262nrGfFMpfisA==", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.12.tgz", + "integrity": "sha512-idIm9mAGDX1qyfA2Ky/1ZJZVMbGydtpIdwl6zl1Yc7FO11IGvAYLh2cH9VsQk98AapRTiJu7QUaRWLLGDaHIcQ==", "dependencies": { "awesome-phonenumber": "^5.4.0", "classnames": "2.5.0", @@ -20786,7 +20786,8 @@ "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" + "ua-parser-js": "^1.0.37", + "underscore": "1.13.6" } }, "node_modules/expensify-common/node_modules/react": { diff --git a/package.json b/package.json index 313d9c169a61..ea1decb5ff8c 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.17", + "expensify-common": "^2.0.12", "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 c058775341c2..a202118bdf5f 100644 --- a/src/libs/OnyxAwareParser.ts +++ b/src/libs/OnyxAwareParser.ts @@ -31,22 +31,12 @@ Onyx.connect({ }, }); -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 parseHtmlToMarkdown(html: string, reportIDToName?: Record, accountIDToName?: Record): string { + return parser.htmlToMarkdown(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}); +function parseHtmlToText(html: string, reportIDToName?: Record, accountIDToName?: Record): string { + return parser.htmlToText(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap}); } export {parseHtmlToMarkdown, parseHtmlToText}; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ec2f9119551e..d0401fb9b393 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1452,23 +1452,19 @@ 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 { +function handleUserDeletedLinksInHtml(newCommentText: string, originalCommentMarkdown: string): string { const parser = new ExpensiMark(); if (newCommentText.length > CONST.MAX_MARKUP_LENGTH) { return newCommentText; } - - const htmlForNewComment = parser.replace(newCommentText, { - extras: {videoAttributeCache}, - }); + const htmlForNewComment = parser.replace(newCommentText); const removedLinks = parser.getRemovedMarkdownLinks(originalCommentMarkdown, newCommentText); return removeLinksFromHtml(htmlForNewComment, removedLinks); } /** Saves a new message for a comment. Marks the comment as edited, which will be reflected in the UI. */ -function editReportComment(reportID: string, originalReportAction: OnyxEntry, textForNewComment: string, videoAttributeCache?: Record) { +function editReportComment(reportID: string, originalReportAction: OnyxEntry, textForNewComment: string) { const parser = new ExpensiMark(); const originalReportID = ReportUtils.getOriginalReportID(reportID, originalReportAction); @@ -1486,8 +1482,8 @@ function editReportComment(reportID: string, originalReportAction: OnyxEntry video attributes -const draftMessageVideoAttributeCache = new Map(); - function ReportActionItemMessageEdit( {action, draftMessage, reportID, index, shouldDisableEmojiPicker = false}: ReportActionItemMessageEditProps, forwardedRef: ForwardedRef, @@ -108,11 +105,7 @@ function ReportActionItemMessageEdit( const isCommentPendingSaved = useRef(false); useEffect(() => { - draftMessageVideoAttributeCache.clear(); - - const originalMessage = parseHtmlToMarkdown(action.message?.[0]?.html ?? '', undefined, undefined, (videoSource, attrs) => { - draftMessageVideoAttributeCache.set(videoSource, attrs); - }); + const originalMessage = parseHtmlToMarkdown(action.message?.[0]?.html ?? ''); if (ReportActionsUtils.isDeletedAction(action) || !!(action.message && draftMessage === originalMessage) || !!(prevDraftMessage === draftMessage || isCommentPendingSaved.current)) { return; } @@ -303,7 +296,7 @@ function ReportActionItemMessageEdit( ReportActionContextMenu.showDeleteModal(reportID, action, true, deleteDraft, () => focusEditAfterCancelDelete(textInputRef.current)); return; } - Report.editReportComment(reportID, action, trimmedNewDraft, Object.fromEntries(draftMessageVideoAttributeCache)); + Report.editReportComment(reportID, action, trimmedNewDraft); deleteDraft(); }, [action, deleteDraft, draft, reportID]);