Skip to content

Commit

Permalink
Merge pull request #46512 from nkdengineer/fix/46486
Browse files Browse the repository at this point in the history
fix: System message shows code when adding emoji in room description
  • Loading branch information
Julesssss authored Jul 31, 2024
2 parents 8e79c59 + 058c406 commit a8f16f1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,15 @@ function getMemberChangeMessageFragment(reportAction: OnyxEntry<ReportAction>):
};
}

function getUpdateRoomDescriptionFragment(reportAction: ReportAction): Message {
const html = getUpdateRoomDescriptionMessage(reportAction);
return {
html: `<muted-text>${html}</muted-text>`,
text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '',
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
};
}

function getMemberChangeMessagePlainText(reportAction: OnyxEntry<ReportAction>): string {
const messageElements = getMemberChangeMessageElements(reportAction);
return messageElements.map((element) => element.content).join('');
Expand Down Expand Up @@ -1607,6 +1616,7 @@ export {
getLatestReportActionFromOnyxData,
getLinkedTransactionID,
getMemberChangeMessageFragment,
getUpdateRoomDescriptionFragment,
getMemberChangeMessagePlainText,
getReportActionMessageFragments,
getMessageOfOldDotReportAction,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ const ContextMenuActions: ContextMenuAction[] = [
Clipboard.setString(Localize.translateLocal(`violationDismissal.${violationName}.${reason}` as TranslationPaths));
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) {
setClipboardMessage(ReportActionsUtils.getExportIntegrationMessageHTML(reportAction));
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
setClipboardMessage(ReportActionsUtils.getUpdateRoomDescriptionMessage(reportAction));
} else if (content) {
setClipboardMessage(
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
Expand Down
9 changes: 7 additions & 2 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,13 @@ function ReportActionItem({
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) {
children = <ReportActionItemBasicMessage message={translate('systemMessage.mergedWithCashTransaction')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
const message = ReportActionsUtils.getUpdateRoomDescriptionMessage(action);
children = <ReportActionItemBasicMessage message={message} />;
children = (
<ReportActionItemMessage
action={action}
reportID={report.reportID}
displayAsGroup={false}
/>
);
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getDismissedViolationMessageText(ReportActionsUtils.getOriginalMessage(action))} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) {
Expand Down
15 changes: 15 additions & 0 deletions src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID,
);
}

if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
const fragment = ReportActionsUtils.getUpdateRoomDescriptionFragment(action);
return (
<View style={[styles.chatItemMessage, style]}>
<TextCommentFragment
fragment={fragment}
displayAsGroup={displayAsGroup}
style={style}
source=""
styleAsDeleted={false}
/>
</View>
);
}

let iouMessage: string | undefined;
if (isIOUReport) {
const originalMessage = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? ReportActionsUtils.getOriginalMessage(action) : null;
Expand Down

0 comments on commit a8f16f1

Please sign in to comment.