Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3293520
D6510.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6510.diff
View Options
diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js
--- a/lib/shared/message-utils.js
+++ b/lib/shared/message-utils.js
@@ -32,6 +32,7 @@
import { type ThreadInfo } from '../types/thread-types';
import type { RelativeUserInfo, UserInfos } from '../types/user-types';
import { type EntityText, entityTextToRawString } from '../utils/entity-text';
+import { pluralize } from '../utils/text-utils';
import { codeBlockRegex, type ParserRules } from './markdown';
import { messageSpecs } from './messages/message-specs';
import { threadIsGroupChat } from './thread-utils';
@@ -67,21 +68,7 @@
}
function robotextForUsers(users: RelativeUserInfo[]): string {
- if (users.length === 1) {
- return robotextForUser(users[0]);
- } else if (users.length === 2) {
- return `${robotextForUser(users[0])} and ${robotextForUser(users[1])}`;
- } else if (users.length === 3) {
- return (
- `${robotextForUser(users[0])}, ${robotextForUser(users[1])}, ` +
- `and ${robotextForUser(users[2])}`
- );
- } else {
- return (
- `${robotextForUser(users[0])}, ${robotextForUser(users[1])}, ` +
- `and ${users.length - 2} others`
- );
- }
+ return pluralize(users.map(robotextForUser), 3);
}
function encodedThreadEntity(threadID: string, text: string): string {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 5:25 PM (22 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2530751
Default Alt Text
D6510.diff (1 KB)
Attached To
Mode
D6510: [lib] Use pluralize in robotextForUsers
Attached
Detach File
Event Timeline
Log In to Comment