Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3498589
D6615.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D6615.diff
View Options
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
@@ -73,13 +73,15 @@
import type { DispatchActionPromise } from '../utils/action-utils';
import type { GetENSNames } from '../utils/ens-helpers';
import {
+ ET,
entityTextToRawString,
getEntityTextAsString,
+ type UserEntity,
} from '../utils/entity-text';
import { values } from '../utils/objects';
import { useSelector } from '../utils/redux-utils';
import { firstLine } from '../utils/string-utils';
-import { pluralize, trimText } from '../utils/text-utils';
+import { trimText } from '../utils/text-utils';
import { type ParserRules } from './markdown';
import { getMessageTitle } from './message-utils';
import { relationshipBlockedInEitherDirection } from './relationship-utils';
@@ -772,28 +774,16 @@
return newPermissions;
}
-function robotextName(
- threadInfo: RawThreadInfo | ThreadInfo,
- viewerID: ?string,
- userInfos: UserInfos,
-): string {
- const threadUsernames = threadOtherMembers(threadInfo.members, viewerID)
- .map(member => userInfos[member.id] && userInfos[member.id].username)
- .filter(Boolean);
- if (threadUsernames.length === 0) {
- return 'just you';
- }
- return pluralize(threadUsernames);
-}
-
function threadUIName(
- threadInfo: RawThreadInfo | ThreadInfo,
- viewerID: ?string,
- userInfos: UserInfos,
-): string {
- return firstLine(
- threadInfo.name || robotextName(threadInfo, viewerID, userInfos),
+ threadInfo: ThreadInfo,
+): string | $ReadOnlyArray<UserEntity> {
+ if (threadInfo.name) {
+ return firstLine(threadInfo.name);
+ }
+ const threadMembers = threadInfo.members.filter(
+ memberInfo => memberInfo.role,
);
+ return threadMembers.map(member => ET.user({ userInfo: member }));
}
function threadInfoFromRawThreadInfo(
@@ -805,7 +795,7 @@
id: rawThreadInfo.id,
type: rawThreadInfo.type,
name: rawThreadInfo.name,
- uiName: threadUIName(rawThreadInfo, viewerID, userInfos),
+ uiName: '',
description: rawThreadInfo.description,
color: rawThreadInfo.color,
creationTime: rawThreadInfo.creationTime,
@@ -817,6 +807,10 @@
currentUser: getCurrentUser(rawThreadInfo, viewerID, userInfos),
repliesCount: rawThreadInfo.repliesCount,
};
+ threadInfo = {
+ ...threadInfo,
+ uiName: threadUIName(threadInfo),
+ };
const { sourceMessageID } = rawThreadInfo;
if (sourceMessageID) {
threadInfo = { ...threadInfo, sourceMessageID };
@@ -1494,7 +1488,6 @@
threadFrozenDueToViewerBlock,
rawThreadInfoFromServerThreadInfo,
filterThreadEditDetailedPermissions,
- robotextName,
threadUIName,
threadInfoFromRawThreadInfo,
rawThreadInfoFromThreadInfo,
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,6 +2,7 @@
import invariant from 'invariant';
+import type { UserEntity } from '../utils/entity-text';
import type { Shape } from './core';
import type { CalendarQuery, RawEntryInfo } from './entry-types';
import type {
@@ -207,7 +208,7 @@
+id: string,
+type: ThreadType,
+name: ?string,
- +uiName: string,
+ +uiName: string | $ReadOnlyArray<UserEntity>,
+description: ?string,
+color: string, // hex, without "#" or "0x"
+creationTime: number, // millisecond timestamp
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';
-type UserEntity = {
+export type UserEntity = {
+type: 'user',
+id: string,
+username?: ?string,
diff --git a/web/modals/threads/settings/thread-settings-modal.react.js b/web/modals/threads/settings/thread-settings-modal.react.js
--- a/web/modals/threads/settings/thread-settings-modal.react.js
+++ b/web/modals/threads/settings/thread-settings-modal.react.js
@@ -52,10 +52,6 @@
deleteThreadLoadingStatusSelector(state) === 'loading' ||
changeThreadSettingsLoadingStatusSelector(state) === 'loading',
);
- const viewerID = useSelector(
- state => state.currentUserInfo && state.currentUserInfo.id,
- );
- const userInfos = useSelector(state => state.userStore.userInfos);
const threadInfo: ?ThreadInfo = useSelector(
state => threadInfoSelector(state)[props.threadID],
);
@@ -76,19 +72,22 @@
const withNoName = { ...threadInfo, name: undefined };
return {
...withNoName,
- uiName: threadUIName(withNoName, viewerID, userInfos),
+ uiName: threadUIName(withNoName),
};
- }, [threadInfo, viewerID, userInfos]);
+ }, [threadInfo]);
const resolvedThreadInfo = useResolvedThreadInfo(threadInfoWithNoName);
const namePlaceholder = resolvedThreadInfo.uiName;
+ const viewerID = useSelector(
+ state => state.currentUserInfo && state.currentUserInfo.id,
+ );
+ const userInfos = useSelector(state => state.userStore.userInfos);
const otherMemberID = React.useMemo(() => {
if (!threadInfo) {
return null;
}
return getSingleOtherUser(threadInfo, viewerID);
}, [threadInfo, viewerID]);
-
const otherUserInfo = otherMemberID ? userInfos[otherMemberID] : null;
const availableRelationshipActions = React.useMemo(() => {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 9:35 PM (17 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683222
Default Alt Text
D6615.diff (5 KB)
Attached To
Mode
D6615: [lib] Update ThreadInfo.uiName to return an array of UserEntities
Attached
Detach File
Event Timeline
Log In to Comment