Skip to content

Commit

Permalink
fix: System message shows code when adding emoji in room description
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed Jul 30, 2024
1 parent df69c80 commit 058c406
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 @@ -1290,6 +1290,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 @@ -1608,6 +1617,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 @@ -420,6 +420,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 @@ -647,8 +647,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 058c406

Please sign in to comment.