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

fix: System message shows code when adding emoji in room description #46512

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading