Page MenuHomePhabricator

D6512.id21807.diff
No OneTemporary

D6512.id21807.diff

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<EntityText>,
+ maxNumberOfNouns: number = 3,
+): EntityText {
+ return basePluralize<EntityText>(
+ nouns,
+ maxNumberOfNouns,
+ [],
+ (a: EntityText | string, b: ?EntityText | string) =>
+ b ? ET`${a}${b}` : ET`${a}`,
+ );
+}
+
+export { ET, entityTextToRawString, entityTextToReact, pluralizeEntityText };

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 7:37 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2531515
Default Alt Text
D6512.id21807.diff (2 KB)

Event Timeline