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 @@ -6,6 +6,7 @@ import _omitBy from 'lodash/fp/omitBy.js'; import * as React from 'react'; +import { getUserAvatarForThread } from './avatar-utils.js'; import { generatePendingThreadColor } from './color-utils.js'; import { type ParserRules } from './markdown.js'; import { extractUserMentionsFromText } from './mention-utils.js'; @@ -50,7 +51,6 @@ getRelativeMemberInfos, usersWithPersonalThreadSelector, } from '../selectors/user-selectors.js'; -import { getUserAvatarForThread } from '../shared/avatar-utils.js'; import type { CalendarQuery } from '../types/entry-types.js'; import { messageTypes } from '../types/message-types-enum.js'; import { @@ -890,26 +890,53 @@ } function threadInfoFromRawThreadInfo( - rawThreadInfo: LegacyRawThreadInfo, + rawThreadInfo: RawThreadInfo, viewerID: ?string, userInfos: UserInfos, ): MinimallyEncodedThreadInfo { - let threadInfo: LegacyThreadInfo = { - id: rawThreadInfo.id, - type: rawThreadInfo.type, - name: rawThreadInfo.name, - uiName: '', - description: rawThreadInfo.description, - color: rawThreadInfo.color, - creationTime: rawThreadInfo.creationTime, - parentThreadID: rawThreadInfo.parentThreadID, - containingThreadID: rawThreadInfo.containingThreadID, - community: rawThreadInfo.community, - members: getRelativeMemberInfos(rawThreadInfo, viewerID, userInfos), - roles: rawThreadInfo.roles, - currentUser: getCurrentUser(rawThreadInfo, viewerID, userInfos), - repliesCount: rawThreadInfo.repliesCount, - }; + let threadInfo: ThreadInfo; + if (rawThreadInfo.minimallyEncoded) { + threadInfo = { + minimallyEncoded: true, + id: rawThreadInfo.id, + type: rawThreadInfo.type, + name: rawThreadInfo.name, + uiName: '', + description: rawThreadInfo.description, + color: rawThreadInfo.color, + creationTime: rawThreadInfo.creationTime, + parentThreadID: rawThreadInfo.parentThreadID, + containingThreadID: rawThreadInfo.containingThreadID, + community: rawThreadInfo.community, + members: getRelativeMemberInfos(rawThreadInfo, viewerID, userInfos), + roles: rawThreadInfo.roles, + currentUser: getMinimallyEncodedCurrentUser( + rawThreadInfo, + viewerID, + userInfos, + ), + repliesCount: rawThreadInfo.repliesCount, + }; + } else { + threadInfo = { + id: rawThreadInfo.id, + type: rawThreadInfo.type, + name: rawThreadInfo.name, + uiName: '', + description: rawThreadInfo.description, + color: rawThreadInfo.color, + creationTime: rawThreadInfo.creationTime, + parentThreadID: rawThreadInfo.parentThreadID, + containingThreadID: rawThreadInfo.containingThreadID, + community: rawThreadInfo.community, + members: getRelativeMemberInfos(rawThreadInfo, viewerID, userInfos), + roles: rawThreadInfo.roles, + currentUser: getCurrentUser(rawThreadInfo, viewerID, userInfos), + repliesCount: rawThreadInfo.repliesCount, + }; + threadInfo = minimallyEncodeThreadInfo(threadInfo); + } + threadInfo = { ...threadInfo, uiName: threadUIName(threadInfo), @@ -934,7 +961,7 @@ if (pinnedCount) { threadInfo = { ...threadInfo, pinnedCount }; } - return minimallyEncodeThreadInfo(threadInfo); + return threadInfo; } function getCurrentUser(