diff --git a/lib/shared/messages/create-sidebar-message-spec.js b/lib/shared/messages/create-sidebar-message-spec.js --- a/lib/shared/messages/create-sidebar-message-spec.js +++ b/lib/shared/messages/create-sidebar-message-spec.js @@ -17,6 +17,11 @@ import type { NotifTexts } from '../../types/notif-types'; import type { ThreadInfo } from '../../types/thread-types'; import type { RelativeUserInfo } from '../../types/user-types'; +import { + ET, + type EntityText, + pluralizeEntityText, +} from '../../utils/entity-text'; import { robotextToRawString, robotextForMessageInfo, @@ -29,7 +34,6 @@ type CreateMessageInfoParams, type MessageSpec, type MessageTitleParam, - type RobotextParams, } from './message-spec'; import { assertSingleMessageInfo } from './utils'; @@ -164,23 +168,22 @@ return { ...messageData, id }; }, - robotext( - messageInfo: CreateSidebarMessageInfo, - creator: string, - params: RobotextParams, - ): string { - let text = `started ${params.encodedThreadEntity( - messageInfo.threadID, - `this thread`, - )}`; + robotext(messageInfo: CreateSidebarMessageInfo): EntityText { + let text = ET`started ${ET.thread({ + display: 'alwaysDisplayShortName', + threadID: messageInfo.threadID, + })}`; const users = messageInfo.initialThreadState.otherMembers.filter( member => member.id !== messageInfo.sourceMessageAuthor.id, ); if (users.length !== 0) { - const initialUsersString = params.robotextForUsers(users); - text += ` and added ${initialUsersString}`; + const initialUsers = pluralizeEntityText( + users.map(user => ET`${ET.user({ userInfo: user })}`), + ); + text = ET`${text} and added ${initialUsers}`; } - return `${creator} ${text}`; + const creator = ET.user({ userInfo: messageInfo.creator }); + return ET`${creator} ${text}`; }, shimUnsupportedMessageInfo( diff --git a/lib/shared/messages/create-thread-message-spec.js b/lib/shared/messages/create-thread-message-spec.js --- a/lib/shared/messages/create-thread-message-spec.js +++ b/lib/shared/messages/create-thread-message-spec.js @@ -15,6 +15,11 @@ import type { NotifTexts } from '../../types/notif-types'; import type { ThreadInfo } from '../../types/thread-types'; import type { RelativeUserInfo } from '../../types/user-types'; +import { + ET, + type EntityText, + pluralizeEntityText, +} from '../../utils/entity-text'; import { robotextToRawString, robotextForMessageInfo, @@ -27,7 +32,6 @@ type MessageSpec, type MessageTitleParam, type NotificationTextsParams, - type RobotextParams, } from './message-spec'; import { assertSingleMessageInfo } from './utils'; @@ -141,32 +145,30 @@ return { ...messageData, id }; }, - robotext( - messageInfo: CreateThreadMessageInfo, - creator: string, - params: RobotextParams, - ): string { - let text = `created ${params.encodedThreadEntity( - messageInfo.threadID, - `this chat`, - )}`; + robotext(messageInfo: CreateThreadMessageInfo): EntityText { + let text = ET`created ${ET.thread({ + display: 'alwaysDisplayShortName', + threadID: messageInfo.threadID, + })}`; const parentThread = messageInfo.initialThreadState.parentThreadInfo; if (parentThread) { - text += - ' as a child of ' + - `<${encodeURI(parentThread.uiName)}|t${parentThread.id}>`; + text = ET`${text} as a child of ${ET.thread({ + display: 'uiName', + threadInfo: parentThread, + })}`; } if (messageInfo.initialThreadState.name) { - text += ` with the name "${encodeURI( - messageInfo.initialThreadState.name, - )}"`; + text = ET`${text} with the name "${messageInfo.initialThreadState.name}"`; } const users = messageInfo.initialThreadState.otherMembers; if (users.length !== 0) { - const initialUsersString = params.robotextForUsers(users); - text += ` and added ${initialUsersString}`; + const initialUsers = pluralizeEntityText( + users.map(user => ET`${ET.user({ userInfo: user })}`), + ); + text = ET`${text} and added ${initialUsers}`; } - return `${creator} ${text}`; + const creator = ET.user({ userInfo: messageInfo.creator }); + return ET`${creator} ${text}`; }, notificationTexts(