diff --git a/lib/shared/messages/add-members-message-spec.js b/lib/shared/messages/add-members-message-spec.js --- a/lib/shared/messages/add-members-message-spec.js +++ b/lib/shared/messages/add-members-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 { values } from '../../utils/objects'; import { robotextForMessageInfo, @@ -26,7 +31,6 @@ MessageSpec, MessageTitleParam, NotificationTextsParams, - RobotextParams, } from './message-spec'; import { joinResult } from './utils'; @@ -122,15 +126,16 @@ return { ...messageData, id }; }, - robotext( - messageInfo: AddMembersMessageInfo, - creator: string, - params: RobotextParams, - ): string { + robotext(messageInfo: AddMembersMessageInfo): EntityText { const users = messageInfo.addedMembers; invariant(users.length !== 0, 'added who??'); - const addedUsersString = params.robotextForUsers(users); - return `${creator} added ${addedUsersString}`; + + const creator = ET.user({ userInfo: messageInfo.creator }); + const addedUsers = pluralizeEntityText( + users.map(user => ET`${ET.user({ userInfo: user })}`), + ); + + return ET`${creator} added ${addedUsers}`; }, notificationTexts( diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js --- a/lib/utils/entity-text.js +++ b/lib/utils/entity-text.js @@ -11,6 +11,7 @@ type RawThreadInfo, type ThreadInfo, } from '../types/thread-types'; +import { basePluralize } from '../utils/text-utils'; type UserEntity = { +type: 'user', @@ -288,4 +289,17 @@ }); } -export { ET, entityTextToRawString, entityTextToReact }; +function pluralizeEntityText( + nouns: $ReadOnlyArray, + maxNumberOfNouns: number = 3, +): EntityText { + return basePluralize( + nouns, + maxNumberOfNouns, + [], + (a: EntityText | string, b: ?EntityText | string) => + b ? ET`${a}${b}` : ET`${a}`, + ); +} + +export { ET, entityTextToRawString, entityTextToReact, pluralizeEntityText };