Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3539493
D9917.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D9917.id.diff
View Options
diff --git a/web/modals/threads/create/steps/subchannel-members-list.react.js b/web/modals/threads/create/steps/subchannel-members-list.react.js
--- a/web/modals/threads/create/steps/subchannel-members-list.react.js
+++ b/web/modals/threads/create/steps/subchannel-members-list.react.js
@@ -5,8 +5,11 @@
import { useENSNames } from 'lib/hooks/ens-cache.js';
import { stringForUser } from 'lib/shared/user-utils.js';
-import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import type { ThreadInfo } from 'lib/types/thread-types.js';
+import type {
+ MinimallyEncodedRelativeMemberInfo,
+ MinimallyEncodedThreadInfo,
+} from 'lib/types/minimally-encoded-thread-permissions-types.js';
+import type { RelativeMemberInfo, ThreadInfo } from 'lib/types/thread-types.js';
import type { UserListItem } from 'lib/types/user-types.js';
import AddMembersList from '../../../components/add-members-list.react.js';
@@ -39,66 +42,52 @@
[parentThreadInfo],
);
- const parentMemberListWithoutENSNames = React.useMemo(() => {
- // Branching to appease `flow`.
- if (parentThreadInfo.minimallyEncoded) {
- return parentThreadInfo.members
+ const filterOutParentMembersWithENSNames = React.useCallback(
+ (
+ members: $ReadOnlyArray<
+ RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo,
+ >,
+ ) =>
+ members
.filter(
user =>
user.id !== currentUserId &&
(searchResult.has(user.id) || searchText.length === 0),
)
- .map(user => ({ id: user.id, username: stringForUser(user) }));
- } else {
- return parentThreadInfo.members
- .filter(
- user =>
- user.id !== currentUserId &&
- (searchResult.has(user.id) || searchText.length === 0),
- )
- .map(user => ({ id: user.id, username: stringForUser(user) }));
- }
- }, [
- currentUserId,
- parentThreadInfo.members,
- parentThreadInfo.minimallyEncoded,
- searchResult,
- searchText.length,
- ]);
+ .map(user => ({ id: user.id, username: stringForUser(user) })),
+ [currentUserId, searchResult, searchText.length],
+ );
+
+ const parentMemberListWithoutENSNames = React.useMemo(
+ () => filterOutParentMembersWithENSNames(parentThreadInfo.members),
+ [filterOutParentMembersWithENSNames, parentThreadInfo.members],
+ );
const parentMemberList = useENSNames<UserListItem>(
parentMemberListWithoutENSNames,
);
- const otherMemberListWithoutENSNames = React.useMemo(() => {
- // Branching to appease `flow`.
- if (communityThreadInfo.minimallyEncoded) {
- return communityThreadInfo.members
+ const filterOutOtherMembersWithENSNames = React.useCallback(
+ (
+ members: $ReadOnlyArray<
+ RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo,
+ >,
+ ) =>
+ members
.filter(
user =>
!parentMembersSet.has(user.id) &&
user.id !== currentUserId &&
(searchResult.has(user.id) || searchText.length === 0),
)
- .map(user => ({ id: user.id, username: stringForUser(user) }));
- } else {
- return communityThreadInfo.members
- .filter(
- user =>
- !parentMembersSet.has(user.id) &&
- user.id !== currentUserId &&
- (searchResult.has(user.id) || searchText.length === 0),
- )
- .map(user => ({ id: user.id, username: stringForUser(user) }));
- }
- }, [
- communityThreadInfo.members,
- communityThreadInfo.minimallyEncoded,
- currentUserId,
- parentMembersSet,
- searchResult,
- searchText.length,
- ]);
+ .map(user => ({ id: user.id, username: stringForUser(user) })),
+ [currentUserId, parentMembersSet, searchResult, searchText.length],
+ );
+
+ const otherMemberListWithoutENSNames = React.useMemo(
+ () => filterOutOtherMembersWithENSNames(communityThreadInfo.members),
+ [communityThreadInfo.members, filterOutOtherMembersWithENSNames],
+ );
const otherMemberList = useENSNames<UserListItem>(
otherMemberListWithoutENSNames,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 2:01 AM (1 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2710098
Default Alt Text
D9917.id.diff (4 KB)
Attached To
Mode
D9917: [web] Pull out `filterOut[Parent/Other]MembersWithENSNames` to remove branching
Attached
Detach File
Event Timeline
Log In to Comment