Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update isReportMessageAttachment logic #8117

Merged
merged 6 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function createOption(personalDetailList, report, {
: {};

const lastActorDetails = report ? _.find(personalDetailList, {login: report.lastActorEmail}) : null;
const lastMessageTextFromReport = ReportUtils.isReportMessageAttachment(lodashGet(report, 'lastMessageText', ''))
const lastMessageTextFromReport = ReportUtils.isReportMessageAttachment({text: lodashGet(report, 'lastMessageText', ''), html: lodashGet(report, 'lastMessageHtml', '')})
? `[${Localize.translateLocal('common.attachment')}]`
: Str.htmlDecode(lodashGet(report, 'lastMessageText', ''));
let lastMessageText = report && hasMultipleParticipants && lastActorDetails
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ function getSimplifiedReportObject(report) {
oldPolicyName,
visibility,
isOwnPolicyExpenseChat: lodashGet(report, ['isOwnPolicyExpenseChat'], false),
lastMessageHtml: lastActionMessage,
};
}

Expand Down Expand Up @@ -628,7 +629,7 @@ function updateReportWithNewAction(
// Add the action into Onyx
reportActionsToMerge[reportAction.sequenceNumber] = {
...reportAction,
isAttachment: ReportUtils.isReportMessageAttachment(messageText),
isAttachment: ReportUtils.isReportMessageAttachment({text: messageText, html: lodashGet(reportAction, ['message', 0, 'html'], '')}),
sobitneupane marked this conversation as resolved.
Show resolved Hide resolved
loading: false,
};

Expand Down
8 changes: 4 additions & 4 deletions src/libs/reportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function getReportParticipantsTitle(logins) {
/**
* Check whether a report action is Attachment is not.
*
* @param {Object} reportMessageText report action's message as text
* @param {Object} reportMessage report action's message as text and html
* @returns {Boolean}
*/
function isReportMessageAttachment(reportMessageText) {
return reportMessageText === '[Attachment]';
function isReportMessageAttachment(reportMessage) {
sobitneupane marked this conversation as resolved.
Show resolved Hide resolved
return lodashGet(reportMessage, 'text', '') === '[Attachment]' && lodashGet(reportMessage, 'html', '') !== '[Attachment]';
sobitneupane marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -60,7 +60,7 @@ function canEditReportAction(reportAction) {
return reportAction.actorEmail === sessionEmail
&& reportAction.reportActionID
&& reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT
&& !isReportMessageAttachment(lodashGet(reportAction, ['message', 0, 'text'], ''));
&& !isReportMessageAttachment({text: lodashGet(reportAction, ['message', 0, 'text'], ''), html: lodashGet(reportAction, ['message', 0, 'html'], '')});
sobitneupane marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default [

const isAttachment = _.has(reportAction, 'isAttachment')
? reportAction.isAttachment
: ReportUtils.isReportMessageAttachment(text);
: ReportUtils.isReportMessageAttachment({text: lodashGet(message, 'text', ''), html});
sobitneupane marked this conversation as resolved.
Show resolved Hide resolved
if (!isAttachment) {
Clipboard.setString(text);
} else {
Expand Down