Skip to content

Commit

Permalink
Merge pull request #45986 from nkdengineer/fix/45522
Browse files Browse the repository at this point in the history
fix: System message for clearing room description
  • Loading branch information
carlosmiceli authored Jul 25, 2024
2 parents f8bb7dd + 846b94a commit 73f9959
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4273,5 +4273,6 @@ export default {
},
roomChangeLog: {
updateRoomDescription: 'set the room description to:',
clearRoomDescription: 'cleared the room description',
},
} satisfies TranslationBase;
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4796,5 +4796,6 @@ export default {
},
roomChangeLog: {
updateRoomDescription: 'establece la descripción de la sala a:',
clearRoomDescription: 'la descripción de la habitación ha sido borrada',
},
} satisfies EnglishTranslation;
12 changes: 11 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxInputOrEntry} from '@src/types/onyx';
import type {JoinWorkspaceResolution, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage';
import type {JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage';
import type Report from '@src/types/onyx/Report';
import type ReportAction from '@src/types/onyx/ReportAction';
import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction';
Expand Down Expand Up @@ -1575,6 +1575,15 @@ function getExportIntegrationActionFragments(reportAction: OnyxEntry<ReportActio
return result;
}

function getUpdateRoomDescriptionMessage(reportAction: ReportAction): string {
const originalMessage = getOriginalMessage(reportAction) as OriginalMessageChangeLog;
if (originalMessage?.description) {
return `${Localize.translateLocal('roomChangeLog.updateRoomDescription')} ${originalMessage?.description}`;
}

return Localize.translateLocal('roomChangeLog.clearRoomDescription');
}

export {
doesReportHaveVisibleActions,
extractLinksFromMessageHtml,
Expand Down Expand Up @@ -1667,6 +1676,7 @@ export {
getExportIntegrationActionFragments,
getExportIntegrationLastMessageText,
getExportIntegrationMessageHTML,
getUpdateRoomDescriptionMessage,
didMessageMentionCurrentUser,
};

Expand Down
5 changes: 1 addition & 4 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,7 @@ function getOptionData({
result.alternateText += `${preposition} ${roomName}`;
}
} else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) {
const lastActionOriginalMessage = ReportActionsUtils.getOriginalMessage(lastAction);
result.alternateText = `${lastActorDisplayName} ${Localize.translate(preferredLocale, 'roomChangeLog.updateRoomDescription')} ${Parser.htmlToText(
lastActionOriginalMessage?.description ?? '',
)}`.trim();
result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`;
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) {
result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace');
} else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) {
Expand Down

0 comments on commit 73f9959

Please sign in to comment.