From 78493ff8a333320cb3f00857286416e4e594ff31 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 16:21:17 +0800 Subject: [PATCH 1/3] copy the action text if available --- .../report/ContextMenu/ContextMenuActions.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index ea25a00ee1d3..d088583417c5 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -32,11 +32,16 @@ import type IconAsset from '@src/types/utils/IconAsset'; import {hideContextMenu, showContextMenu, showDeleteModal} from './ReportActionContextMenu'; /** Gets the HTML version of the message in an action */ -function getActionText(reportAction: OnyxEntry): string { +function getActionHtml(reportAction: OnyxEntry): string { const message = reportAction?.message?.at(-1) ?? null; return message?.html ?? ''; } +/** Gets the text version of the message in an action */ +function getActionText(reportAction: OnyxEntry): string { + return reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, '') ?? ''; +} + /** Sets the HTML string to Clipboard */ function setClipboardMessage(content: string) { const parser = new ExpensiMark(); @@ -162,7 +167,7 @@ const ContextMenuActions: ContextMenuAction[] = [ ); }, onPress: (closePopover, {reportAction}) => { - const html = getActionText(reportAction); + const html = getActionHtml(reportAction); const {originalFileName, sourceURL} = getAttachmentDetails(html); const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? ''); const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; @@ -220,7 +225,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } const editAction = () => { if (!draftMessage) { - Report.saveReportActionDraft(reportID, reportAction, getActionText(reportAction)); + Report.saveReportActionDraft(reportID, reportAction, getActionHtml(reportAction)); } else { Report.deleteReportActionDraft(reportID, reportAction); } @@ -371,7 +376,8 @@ const ContextMenuActions: ContextMenuAction[] = [ onPress: (closePopover, {reportAction, selection}) => { const isTaskAction = ReportActionsUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); - const messageHtml = isTaskAction ? TaskUtils.getTaskReportActionMessage(reportAction?.actionName) : getActionText(reportAction); + const messageHtml = isTaskAction ? TaskUtils.getTaskReportActionMessage(reportAction?.actionName) : getActionHtml(reportAction); + const messageText = getActionText(reportAction); const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction); if (!isAttachment) { @@ -392,11 +398,10 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (ReportActionsUtils.isMemberChangeAction(reportAction)) { const logMessage = ReportActionsUtils.getMemberChangeMessageFragment(reportAction).html ?? ''; setClipboardMessage(logMessage); - } else if (ReportActionsUtils.isSubmittedExpenseAction(reportAction)) { - const submittedMessage = reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, ''); - Clipboard.setString(submittedMessage ?? ''); } else if (content) { setClipboardMessage(content); + } else if (messageText) { + Clipboard.setString(messageText) } } From 67307aec0252dae8d764dc4d05f0c867d0ff35ed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 16:21:24 +0800 Subject: [PATCH 2/3] remove unused function --- src/libs/ReportActionsUtils.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index f967cb244268..a7d6438809e0 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -111,10 +111,6 @@ function isModifiedExpenseAction(reportAction: OnyxEntry): boolean return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE; } -function isSubmittedExpenseAction(reportAction: OnyxEntry): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED; -} - function isWhisperAction(reportAction: OnyxEntry): boolean { return (reportAction?.whisperedToAccountIDs ?? []).length > 0; } @@ -834,7 +830,6 @@ export { isDeletedParentAction, isMessageDeleted, isModifiedExpenseAction, - isSubmittedExpenseAction, isMoneyRequestAction, isNotifiableReportAction, isPendingRemove, From 5f205e741b366a981f4eb215fef03c6f9b628589 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 16:39:06 +0800 Subject: [PATCH 3/3] prettier --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index d088583417c5..52ee7d3c269d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -401,7 +401,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (content) { setClipboardMessage(content); } else if (messageText) { - Clipboard.setString(messageText) + Clipboard.setString(messageText); } }