Page MenuHomePhabricator

D10807.id36118.diff
No OneTemporary

D10807.id36118.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 {
AccountUserInfo,
CurrentUserInfo,
@@ -54,55 +51,35 @@
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, Nov 27, 7:19 PM (20 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591432
Default Alt Text
D10807.id36118.diff (2 KB)

Event Timeline