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 for clearing room description #45986

Merged
merged 3 commits into from
Jul 25, 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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4272,5 +4272,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 @@ -4795,5 +4795,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
Loading