Page MenuHomePhabricator

D9848.diff
No OneTemporary

D9848.diff

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
@@ -114,6 +114,7 @@
entityTextToRawString,
getEntityTextAsString,
type ThreadEntity,
+ type UserEntity,
} from '../utils/entity-text.js';
import { useSelector } from '../utils/redux-utils.js';
import { firstLine } from '../utils/string-utils.js';
@@ -935,16 +936,26 @@
return rawThreadInfo;
}
-function threadUIName(threadInfo: ThreadInfo): string | ThreadEntity {
+function threadUIName(
+ threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+): string | ThreadEntity {
if (threadInfo.name) {
return firstLine(threadInfo.name);
}
- const threadMembers = threadInfo.members.filter(
- memberInfo => memberInfo.role,
- );
- const memberEntities = threadMembers.map(member =>
- ET.user({ userInfo: member }),
- );
+
+ let threadMembers:
+ | $ReadOnlyArray<MinimallyEncodedRelativeMemberInfo>
+ | $ReadOnlyArray<RelativeMemberInfo>;
+ let memberEntities: $ReadOnlyArray<UserEntity>;
+ // Branching below is to appease flow
+ if (threadInfo.minimallyEncoded) {
+ threadMembers = threadInfo.members.filter(memberInfo => memberInfo.role);
+ memberEntities = threadMembers.map(member => ET.user({ userInfo: member }));
+ } else {
+ threadMembers = threadInfo.members.filter(memberInfo => memberInfo.role);
+ memberEntities = threadMembers.map(member => ET.user({ userInfo: member }));
+ }
+
return {
type: 'thread',
id: threadInfo.id,
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
@@ -17,7 +17,7 @@
import { type RawThreadInfo, type ThreadInfo } from '../types/thread-types.js';
import { basePluralize } from '../utils/text-utils.js';
-type UserEntity = {
+export type UserEntity = {
+type: 'user',
+id: string,
+username?: ?string,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 15, 6:06 PM (20 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2494979
Default Alt Text
D9848.diff (1 KB)

Event Timeline