Page MenuHomePhabricator

D6510.diff
No OneTemporary

D6510.diff

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

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)

Event Timeline