Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3528126
D10807.id36327.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10807.id36327.diff
View Options
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,
@@ -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
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 8:19 AM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702039
Default Alt Text
D10807.id36327.diff (2 KB)
Attached To
Mode
D10807: [lib] Remove support for `LegacyRawThreadInfo` in `getRelativeMemberInfos`
Attached
Detach File
Event Timeline
Log In to Comment