Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33044512
D6696.1768417617.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D6696.1768417617.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
@@ -20,9 +20,8 @@
import {
ET,
getEntityTextAsString,
- pluralizeEntityText,
type EntityText,
- type UserEntity,
+ type ThreadEntity,
} from '../utils/entity-text.js';
import { promiseAll } from '../utils/promises.js';
import { trimText } from '../utils/text-utils.js';
@@ -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
@@ -83,7 +83,7 @@
ET,
entityTextToRawString,
getEntityTextAsString,
- type UserEntity,
+ type ThreadEntity,
} from '../utils/entity-text.js';
import { values } from '../utils/objects.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -777,16 +777,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.js';
+import type { EntityText, ThreadEntity } from '../utils/entity-text.js';
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
@@ -11,7 +11,7 @@
import type { ThreadSubscription } from './subscription-types.js';
import type { ServerUpdateInfo, ClientUpdateInfo } from './update-types.js';
import type { UserInfo, UserInfos } from './user-types.js';
-import type { UserEntity } from '../utils/entity-text.js';
+import type { ThreadEntity } from '../utils/entity-text.js';
export const threadTypes = Object.freeze({
//OPEN: 0, (DEPRECATED)
@@ -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 @@
} from '../types/thread-types.js';
import { basePluralize } from '../utils/text-utils.js';
-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
Wed, Jan 14, 7:06 PM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5933068
Default Alt Text
D6696.1768417617.diff (5 KB)
Attached To
Mode
D6696: [lib] Return ThreadEntity from ThreadInfo.uiName
Attached
Detach File
Event Timeline
Log In to Comment