Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3495369
D6696.id22350.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D6696.id22350.diff
View Options
diff --git a/lib/shared/notif-utils.js b/lib/shared/notif-utils.js
--- a/lib/shared/notif-utils.js
+++ b/lib/shared/notif-utils.js
@@ -17,9 +17,8 @@
import {
ET,
getEntityTextAsString,
- pluralizeEntityText,
type EntityText,
- type UserEntity,
+ type ThreadEntity,
} from '../utils/entity-text';
import { promiseAll } from '../utils/promises';
import { trimText } from '../utils/text-utils';
@@ -98,7 +97,7 @@
+threadType: ThreadType,
+parentThreadInfo: ThreadInfo,
+childThreadName: ?string,
- +childThreadUIName: string | $ReadOnlyArray<UserEntity>,
+ +childThreadUIName: string | ThreadEntity,
};
function notifTextsForSubthreadCreation(
input: NotifTextsForSubthreadCreationInput,
@@ -181,15 +180,10 @@
);
return notifString;
};
- const unresolvedTitle = unresolvedNotifTexts.title;
- const pluralizedTitle =
- typeof unresolvedTitle === 'string'
- ? unresolvedTitle
- : pluralizeEntityText(unresolvedTitle.map(entity => [entity]));
let promises = {
merged: resolveToString(unresolvedNotifTexts.merged),
body: resolveToString(unresolvedNotifTexts.body),
- title: resolveToString(pluralizedTitle),
+ title: resolveToString(ET`${unresolvedNotifTexts.title}`),
};
if (unresolvedNotifTexts.prefix) {
promises = {
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -76,7 +76,7 @@
ET,
entityTextToRawString,
getEntityTextAsString,
- type UserEntity,
+ type ThreadEntity,
} from '../utils/entity-text';
import { values } from '../utils/objects';
import { useSelector } from '../utils/redux-utils';
@@ -774,16 +774,23 @@
return newPermissions;
}
-function threadUIName(
- threadInfo: ThreadInfo,
-): string | $ReadOnlyArray<UserEntity> {
+function threadUIName(threadInfo: ThreadInfo): string | ThreadEntity {
if (threadInfo.name) {
return firstLine(threadInfo.name);
}
const threadMembers = threadInfo.members.filter(
memberInfo => memberInfo.role,
);
- return threadMembers.map(member => ET.user({ userInfo: member }));
+ const memberEntities = threadMembers.map(member =>
+ ET.user({ userInfo: member }),
+ );
+ return {
+ type: 'thread',
+ id: threadInfo.id,
+ name: threadInfo.name,
+ display: 'uiName',
+ uiName: memberEntities,
+ };
}
function threadInfoFromRawThreadInfo(
diff --git a/lib/types/notif-types.js b/lib/types/notif-types.js
--- a/lib/types/notif-types.js
+++ b/lib/types/notif-types.js
@@ -1,11 +1,11 @@
// @flow
-import type { EntityText, UserEntity } from '../utils/entity-text';
+import type { EntityText, ThreadEntity } from '../utils/entity-text';
export type NotifTexts = {
+merged: string | EntityText,
+body: string | EntityText,
- +title: string | $ReadOnlyArray<UserEntity>,
+ +title: string | ThreadEntity,
+prefix?: string | EntityText,
};
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
-import type { UserEntity } from '../utils/entity-text';
+import type { ThreadEntity } from '../utils/entity-text';
import type { Shape } from './core';
import type { CalendarQuery, RawEntryInfo } from './entry-types';
import type {
@@ -208,7 +208,7 @@
+id: string,
+type: ThreadType,
+name: ?string,
- +uiName: string | $ReadOnlyArray<UserEntity>,
+ +uiName: string | ThreadEntity,
+description: ?string,
+color: string, // hex, without "#" or "0x"
+creationTime: number, // millisecond timestamp
diff --git a/lib/utils/entity-helpers.js b/lib/utils/entity-helpers.js
--- a/lib/utils/entity-helpers.js
+++ b/lib/utils/entity-helpers.js
@@ -15,10 +15,7 @@
threadInfos: $ReadOnlyArray<ThreadInfo>,
): $ReadOnlyArray<ResolvedThreadInfo> {
const entityText = React.useMemo(
- () =>
- threadInfos.map(threadInfo =>
- ET.thread({ display: 'uiName', threadInfo }),
- ),
+ () => threadInfos.map(threadInfo => threadInfo.uiName),
[threadInfos],
);
const withENSNames = useENSNamesForEntityText(entityText);
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
@@ -15,7 +15,7 @@
import { basePluralize } from '../utils/text-utils';
import type { GetENSNames } from './ens-helpers';
-export type UserEntity = {
+type UserEntity = {
+type: 'user',
+id: string,
+username?: ?string,
@@ -24,7 +24,7 @@
};
// Comments explain how thread name will appear from user4's perspective
-type ThreadEntity =
+export type ThreadEntity =
| {
+type: 'thread',
+id: string,
@@ -119,6 +119,9 @@
entityTextFunction.thread = (input: EntityTextThreadInput) => {
if (input.display === 'uiName') {
const { threadInfo } = input;
+ if (typeof threadInfo.uiName !== 'string') {
+ return threadInfo.uiName;
+ }
return {
type: 'thread',
id: threadInfo.id,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 8:24 AM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2681160
Default Alt Text
D6696.id22350.diff (4 KB)
Attached To
Mode
D6696: [lib] Return ThreadEntity from ThreadInfo.uiName
Attached
Detach File
Event Timeline
Log In to Comment