Page MenuHomePhabricator

D10807.id36337.diff
No OneTemporary

D10807.id36337.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
@@ -16,10 +16,7 @@
import type { BaseAppState } from '../types/redux-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
-import type {
- LegacyRawThreadInfo,
- RawThreadInfos,
-} from '../types/thread-types.js';
+import type { RawThreadInfos } from '../types/thread-types.js';
import type {
UserInfos,
RelativeUserInfo,
@@ -37,72 +34,49 @@
const relativeUserInfos: RelativeUserInfo[] = [];
for (const userID of userIDs) {
const username = userInfos[userID] ? userInfos[userID].username : null;
+ const relativeUserInfo = {
+ id: userID,
+ username,
+ isViewer: userID === viewerID,
+ };
if (userID === viewerID) {
- relativeUserInfos.unshift({
- id: userID,
- username,
- isViewer: true,
- });
+ relativeUserInfos.unshift(relativeUserInfo);
} else {
- relativeUserInfos.push({
- id: userID,
- username,
- isViewer: false,
- });
+ relativeUserInfos.push(relativeUserInfo);
}
}
return relativeUserInfos;
}
-type ExtractArrayParam = <T>(arr: $ReadOnlyArray<T>) => T;
-
-function getRelativeMemberInfos<TI: RawThreadInfo | LegacyRawThreadInfo>(
- threadInfo: ?TI,
+function getRelativeMemberInfos(
+ threadInfo: ?RawThreadInfo,
currentUserID: ?string,
userInfos: UserInfos,
-): $ReadOnlyArray<
- $ReadOnly<{
- ...$Call<ExtractArrayParam, $PropertyType<TI, 'members'>>,
- +username: ?string,
- +isViewer: boolean,
- }>,
-> {
- const relativeMemberInfos: Array<
- $ReadOnly<{
- ...$Call<ExtractArrayParam, $PropertyType<TI, 'members'>>,
- +username: ?string,
- +isViewer: boolean,
- }>,
- > = [];
+): $ReadOnlyArray<RelativeMemberInfo> {
+ const relativeMemberInfos: RelativeMemberInfo[] = [];
if (!threadInfo) {
return relativeMemberInfos;
}
const memberInfos = threadInfo.members;
- for (const memberInfoInput of memberInfos) {
- const memberInfo: $Call<
- ExtractArrayParam,
- $PropertyType<TI, 'members'>,
- > = memberInfoInput;
+ for (const memberInfo of memberInfos) {
if (!memberInfo.role) {
continue;
}
- const username: ?string = userInfos[memberInfo.id]
+ const username = userInfos[memberInfo.id]
? userInfos[memberInfo.id].username
: null;
- const isViewer: boolean = memberInfo.id === currentUserID;
- const relativeMemberInfo: $ReadOnly<{
- ...$Call<ExtractArrayParam, $PropertyType<TI, 'members'>>,
- +username: ?string,
- +isViewer: boolean,
- }> = {
- ...memberInfo,
- username,
- isViewer,
- };
- if (isViewer) {
- relativeMemberInfos.unshift(relativeMemberInfo);
+ if (memberInfo.id === currentUserID) {
+ relativeMemberInfos.unshift({
+ ...memberInfo,
+ username,
+ isViewer: true,
+ });
} else {
- relativeMemberInfos.push(relativeMemberInfo);
+ relativeMemberInfos.push({
+ ...memberInfo,
+ username,
+ isViewer: false,
+ });
}
}
return relativeMemberInfos;

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 8:19 AM (10 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702035
Default Alt Text
D10807.id36337.diff (3 KB)

Event Timeline