Page MenuHomePhabricator

D10235.id34391.diff
No OneTemporary

D10235.id34391.diff

diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -11,6 +11,10 @@
import SentencePrefixSearchIndex from '../shared/sentence-prefix-search-index.js';
import { getSingleOtherUser } from '../shared/thread-utils.js';
import type { ClientEmojiAvatar } from '../types/avatar-types';
+import type {
+ MinimallyEncodedRawThreadInfo,
+ MinimallyEncodedRelativeMemberInfo,
+} from '../types/minimally-encoded-thread-permissions-types.js';
import type { BaseAppState } from '../types/redux-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
@@ -54,7 +58,41 @@
return relativeUserInfos;
}
-function getRelativeMemberInfos(
+function getMinimallyEncodedRelativeMemberInfos(
+ threadInfo: ?MinimallyEncodedRawThreadInfo,
+ currentUserID: ?string,
+ userInfos: UserInfos,
+): $ReadOnlyArray<MinimallyEncodedRelativeMemberInfo> {
+ const relativeMemberInfos = [];
+ if (!threadInfo) {
+ return relativeMemberInfos;
+ }
+ const memberInfos = threadInfo.members;
+ for (const memberInfo of memberInfos) {
+ if (!memberInfo.role) {
+ continue;
+ }
+ const username = userInfos[memberInfo.id]
+ ? userInfos[memberInfo.id].username
+ : null;
+ if (memberInfo.id === currentUserID) {
+ relativeMemberInfos.unshift({
+ ...memberInfo,
+ username,
+ isViewer: true,
+ });
+ } else {
+ relativeMemberInfos.push({
+ ...memberInfo,
+ username,
+ isViewer: false,
+ });
+ }
+ }
+ return relativeMemberInfos;
+}
+
+function getLegacyRelativeMemberInfos(
threadInfo: ?LegacyRawThreadInfo,
currentUserID: ?string,
userInfos: UserInfos,
@@ -104,7 +142,7 @@
(state: BaseAppState<>) =>
state.currentUserInfo && state.currentUserInfo.id,
(state: BaseAppState<>) => state.userStore.userInfos,
- getRelativeMemberInfos,
+ getLegacyRelativeMemberInfos,
);
};
@@ -241,7 +279,8 @@
export {
userIDsToRelativeUserInfos,
- getRelativeMemberInfos,
+ getMinimallyEncodedRelativeMemberInfos,
+ getLegacyRelativeMemberInfos,
relativeMemberInfoSelectorForMembersOfThread,
userInfoSelectorForPotentialMembers,
userSearchIndexForPotentialMembers,
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
@@ -47,7 +47,7 @@
threadInfosSelectorForThreadType,
} from '../selectors/thread-selectors.js';
import {
- getRelativeMemberInfos,
+ getLegacyRelativeMemberInfos,
usersWithPersonalThreadSelector,
} from '../selectors/user-selectors.js';
import { getUserAvatarForThread } from '../shared/avatar-utils.js';
@@ -904,7 +904,7 @@
parentThreadID: rawThreadInfo.parentThreadID,
containingThreadID: rawThreadInfo.containingThreadID,
community: rawThreadInfo.community,
- members: getRelativeMemberInfos(rawThreadInfo, viewerID, userInfos),
+ members: getLegacyRelativeMemberInfos(rawThreadInfo, viewerID, userInfos),
roles: rawThreadInfo.roles,
currentUser: getCurrentUser(rawThreadInfo, viewerID, userInfos),
repliesCount: rawThreadInfo.repliesCount,

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 8:19 AM (9 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702045
Default Alt Text
D10235.id34391.diff (3 KB)

Event Timeline